Webpack Nomodule Plugin
nomodule attribute to script tags injected by Html Webpack Plugin
- Install via
npm i -D webpack-nomodule-plugin
- Add to your webpack config AFTER HtmlWebpackPlugin
var NoModulePlugin = WebpackNoModulePlugin;// OR for import style...plugins:filename:hash: falseinject: 'body'minify: minifyOptionsshowErrors: falsetemplate: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 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.