html-webpack-plugin-crossorigin

1.0.8 • Public • Published

HTML Webpack Plugin Cross Origin (Webpack 4)

This plugin adapt html-webpack-inject-attributes-plugin(v1.0.0) for webpack 4.

npm i --save-dev html-webpack-plugin-crossorigin

Usage

const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackPluginCrossorigin = require('html-webpack-plugin-crossorigin');
 
new HtmlWebpackPlugin({
    plugins: [
        new HtmlWebpackPlugin({
            filename: 'test.html',
            template: 'src/assets/test.html'
            // add script attributes here!
            attributes: {
                crossorigin: 'anonymous'
            }
        }),
        // this one should be placed after HtmlWebpackPlugin
        new HtmlWebpackPluginCrossorigin({
            inject: true
        })
    ]
});

It will add the crossorigin=anonymous to script tag like:

<script src="index.js" crossorigin="anonymous"></script>

This plugin fixed the problem from the origin one:

ERROR in TypeError: callback is not a function

  • index.js:35 [ex-child-webpack]/[html-webpack-inject-attributes-plugin]/index.js:35:13

Package Sidebar

Install

npm i html-webpack-plugin-crossorigin

Weekly Downloads

250

Version

1.0.8

License

MIT

Unpacked Size

3.53 kB

Total Files

3

Last publish

Collaborators

  • yincheng