hwp-attributes-plugin v2.2.1
hwp-attributes-plugin
Plugin to add various attributes to script tags injected by html-webpack-plugin
Installation
npm i -D hwp-attributes-pluginUsage
import { HwpAttributesPlugin } from 'hwp-attributes-plugin';
// Webpack configuration object
export default {
plugins: [
new HtmlWebpackPlugin({ /* ... */ }),
new HwpAttributesPlugin({
module: ['**.mjs'],
nomodule: ['polyfills.js'],
async: ['some-async-script.js', 'another-async-script.js'],
defer: ['script-to-defer.*.js'],
}),
],
};To configure the plugin, pass an object with the following keys to its constructor (all keys are optional):
module: patterns of scripts that should have themoduleattribute added;nomodule: patterns of scripts that should have thenomoduleattribute added;async: patterns of scripts that should have theasyncattribute added;defer: patterns of scripts that should have thedeferattribute added.
The plugin performs pattern matching with the help of minimatch.
The module and nomodule attributes are mutually exclusive, module takes precedence. If the same file matches both module and nomodule patterns, it will have the module attribute.
1 year ago
1 year ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago