npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

webpack-nomodule-plugin

1.0.1 • Public • Published

Webpack Nomodule Plugin

Assigns the nomodule attribute to script tags injected by Html Webpack Plugin

Configuration

  1. Install via npm i -D webpack-nomodule-plugin
  2. Add to your webpack config AFTER HtmlWebpackPlugin
    var NoModulePlugin = require('webpack-nomodule-plugin').WebpackNoModulePlugin;
    // OR for import style
    import {WebpackNoModulePlugin} from 'webpack-nomodule-plugin'
    ...
    plugins: [
        new HtmlWebpackPlugin({
            filename: join(OUTPUT_DIR, './dist/index.html'),
            hash: false,
            inject: 'body',
            minify: minifyOptions,
            showErrors: false
            template: join(__dirname, './src/index.html'),
        }),
        new WebpackNoModulePlugin({
            filePatterns: ['polyfill.**.js']
        })
    ]

The plugin takes a configuration argument with a key called filePatterns. This is an array of file globs (provided via minimatch) representing which injected script tags to flag as nomodule. Scripts with this attribute will not be executed on newer browsers, so IE and other browser polyfills can be skipped if not needed.

Testing

Testing is done via ts-node and mocha. Test files can be found in /spec, and will be auto-discovered as long as the file ends in .spec.ts. Just run npm test after installing to see the tests run.

install

npm i webpack-nomodule-plugin

Downloadsweekly downloads

222

version

1.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability