1.0.15 • Published 3 years ago

webpack_script_cross v1.0.15

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

webpack_script_cross

English | 简体中文

✨ Features

  • Zero-config, easy to use
  • Support webpack v4/5
  • Support html-webpack-plugin v4/5
  • 零配置/极简使用
  • 支持 webpack 版本 v4/5
  • 支持 html-webpack-plugin 版本 v4/5

🚀 QuickStart

Install

 npm i  webpack_script_cross -D

Usage

Please put it after HtmlWebpackPlugin

const WebpackScriptCross = require('webpack_script_cross')

const webpackConfig = {
  /* ... */
  plugins: [
    new HtmlWebpackPlugin(), // inject must be true (by default)
    new WebpackScriptCross(),
  ],
  /* ... */
  output:{
    /* ... */
      crossOriginLoading:"anonymous" // Spa should have this to add (crossorigin) to script tag dynamically.
      // crossOriginLoading:"anonymous"  only works when script.src is  different from site's origin
    /* ... */
  }
}

Attention: if this not working in react project, please ensure the version of react-scripts >= "^4.0.1"

Config

Default config: { crossorigin: 'anonymous',debug:false }

new WebpackScriptCross({ 
  crossorigin: 'anonymous', // optional
  debug:false  // optional
})

Changelog

License

MIT

Copyright (c) 2020-present, yangshan.andy