Gathering detailed insights and metrics for rrd-html-webpack-include-assets-plugin
Gathering detailed insights and metrics for rrd-html-webpack-include-assets-plugin
Gathering detailed insights and metrics for rrd-html-webpack-include-assets-plugin
Gathering detailed insights and metrics for rrd-html-webpack-include-assets-plugin
lets you define html tags to inject with html-webpack-plugin
npm install rrd-html-webpack-include-assets-plugin
Typescript
Module System
Node Version
NPM Version
69.8
Supply Chain
98.8
Quality
73.9
Maintenance
100
Vulnerability
98.6
License
JavaScript (100%)
Total Downloads
1,530
Last Day
1
Last Week
5
Last Month
27
Last Year
175
MIT License
257 Stars
296 Commits
31 Forks
2 Watchers
10 Branches
11 Contributors
Updated on May 13, 2025
Minified
Minified + Gzipped
Latest Version
1.0.6
Package Id
rrd-html-webpack-include-assets-plugin@1.0.6
Unpacked Size
24.47 kB
Size
6.28 kB
File Count
4
NPM Version
5.6.0
Node Version
10.1.0
Cumulative downloads
Total Downloads
Enhances html-webpack-plugin functionality by allowing you to specify js or css assets to be included.
When using a plugin such as copy-webpack-plugin you may have assets output to your build directory that are not detected/output by the html-webpack-plugin.
This plugin allows you to force some of these assets to be included in the output from html-webpack-plugin.
You must be running webpack on node 4.x or higher
Install the plugin with npm:
1$ npm install --save-dev html-webpack-include-assets-plugin
Require the plugin in your webpack config:
1var HtmlWebpackIncludeAssetsPlugin = require('html-webpack-include-assets-plugin');
Add the plugin to your webpack config as follows:
1plugins: [ 2 new HtmlWebpackPlugin(), 3 new HtmlWebpackIncludeAssetsPlugin({ assets: [], append: true }) 4]
The available options are:
jsExtensions
: string
or array
Specifies the file extensions to use to determine if assets are script assets. Default is ['.js']
.
cssExtensions
: string
or array
Specifies the file extensions to use to determine if assets are style assets. Default is ['.css']
.
assets
: string
or array
or object
Assets that will be output into your html-webpack-plugin template.
To specify just one asset, simply pass a string or object. To specify multiple, pass an array of strings or objects.
If the asset path is static and ends in one of the jsExtensions
or cssExtensions
values, simply use a string value.
If the asset is not static or does not have a valid extension, you can instead pass an object with properties path
(required) and type
or glob
or globPath
or attributes
(optional). In this case path
is the asset href/src, type
is one of js
or css
, and glob
is a wildcard to use to match all files in the path (uses the glob package). The globPath
can be used to specify the directory from which the glob
should search for filename matches (the default is to use path
within webpack's output directory).
The attributes
property may be used to add additional attributes to the link or script element that is injected. The keys of this object are attribute names and the values are the attribute values.
append
: boolean
Specifying whether the assets should be prepended (false
) before any existing assets, or appended (true
) after them.
publicPath
: boolean
or string
Specifying whether the assets should be prepended with webpack's public path or a custom publicPath (string
).
A value of false
may be used to disable prefixing with webpack's publicPath, or a value like myPublicPath/
may be used to prefix all assets with the given string. Default is true
.
hash
: boolean
Specifying whether the assets should be appended with webpack's compilation hash. This is useful for cache busting. Default is false
.
files
: string
or array
Files that the assets will be added to.
By default the assets will be included in all files. If files are defined, the assets will only be included in specified file globs (uses the minimatch package).
Using HtmlWebpackIncludeAssetsPlugin
and CopyWebpackPlugin
to include assets to html-webpack-plugin
template :
1plugins: [ 2 new CopyWebpackPlugin([ 3 { from: 'node_modules/bootstrap/dist/css', to: 'css/'}, 4 { from: 'node_modules/bootstrap/dist/fonts', to: 'fonts/'} 5 ]), 6 new HtmlWebpackPlugin(), 7 new HtmlWebpackIncludeAssetsPlugin({ 8 assets: ['css/bootstrap.min.css', 'css/bootstrap-theme.min.css'], 9 append: false 10 }) 11]
Appending and prepending at the same time :
1plugins: [ 2 new CopyWebpackPlugin([ 3 { from: 'node_modules/bootstrap/dist/css', to: 'css/'}, 4 { from: 'node_modules/bootstrap/dist/fonts', to: 'fonts/'} 5 ]), 6 new HtmlWebpackPlugin(), 7 new HtmlWebpackIncludeAssetsPlugin({ 8 assets: ['css/bootstrap.min.css', 'css/bootstrap-theme.min.css'], 9 append: false 10 }), 11 new HtmlWebpackIncludeAssetsPlugin({ 12 assets: ['css/custom.css'], 13 append: true 14 }) 15]
Using custom jsExtensions
:
1plugins: [ 2 new HtmlWebpackPlugin(), 3 new HtmlWebpackIncludeAssetsPlugin({ 4 assets: ['dist/output.js', 'lib/content.jsx'], 5 append: false, 6 jsExtensions: ['.js', '.jsx'] 7 }) 8]
Using custom publicPath
:
1plugins: [ 2 new CopyWebpackPlugin([ 3 { from: 'node_modules/bootstrap/dist/css', to: 'css/'}, 4 { from: 'node_modules/bootstrap/dist/fonts', to: 'fonts/'} 5 ]), 6 new HtmlWebpackPlugin(), 7 new HtmlWebpackIncludeAssetsPlugin({ 8 assets: ['css/bootstrap.min.css', 'css/bootstrap-theme.min.css'], 9 append: false, 10 publicPath: 'myPublicPath/' 11 }) 12]
Or to include assets without prepending the publicPath
:
1plugins: [ 2 new HtmlWebpackPlugin(), 3 new HtmlWebpackIncludeAssetsPlugin({ 4 assets: ['css/no-public-path.min.css', 'http://some.domain.com.js'], 5 append: false, 6 publicPath: false 7 }) 8]
Manually specifying asset types :
1plugins: [ 2 new CopyWebpackPlugin([ 3 { from: 'node_modules/bootstrap/dist/css', to: 'css/'}, 4 { from: 'node_modules/bootstrap/dist/fonts', to: 'fonts/'} 5 ]), 6 new HtmlWebpackPlugin(), 7 new HtmlWebpackIncludeAssetsPlugin({ 8 assets: [ 9 '/css/bootstrap.min.css', 10 '/css/bootstrap-theme.min.css', 11 { path: 'https://fonts.googleapis.com/css?family=Material+Icons', type: 'css' } 12 ], 13 append: false, 14 publicPath: '' 15 }) 16]
Adding custom attributes to asset tags :
The bootstrap-theme link tag will be given an id="bootstrapTheme" attribute.
1plugins: [ 2 new CopyWebpackPlugin([ 3 { from: 'node_modules/bootstrap/dist/css', to: 'css/'}, 4 { from: 'node_modules/bootstrap/dist/fonts', to: 'fonts/'} 5 ]), 6 new HtmlWebpackPlugin(), 7 new HtmlWebpackIncludeAssetsPlugin({ 8 assets: [ 9 '/css/bootstrap.min.css', 10 { path: '/css/bootstrap-theme.min.css', attributes: { id: 'bootstrapTheme' } } 11 ], 12 append: false, 13 publicPath: '' 14 }) 15]
Using hash
option :
All asset paths will be appended with a hash query parameter (?hash=<the_hash>
)
1plugins: [ 2 new CopyWebpackPlugin([ 3 { from: 'node_modules/bootstrap/dist/css', to: 'css/'}, 4 { from: 'node_modules/bootstrap/dist/fonts', to: 'fonts/'} 5 ]), 6 new HtmlWebpackPlugin(), 7 new HtmlWebpackIncludeAssetsPlugin({ 8 assets: ['css/bootstrap.min.css', 'css/bootstrap-theme.min.css'], 9 append: false, 10 hash: true 11 }) 12]
Specifying specific files
1plugins: [ 2 new CopyWebpackPlugin([ 3 { from: 'node_modules/bootstrap/dist/css', to: 'css/'}, 4 { from: 'node_modules/bootstrap/dist/fonts', to: 'fonts/'} 5 ]), 6 new HtmlWebpackPlugin({ 7 filename: 'a/index.html' 8 }), 9 new HtmlWebpackPlugin({ 10 filename: 'b/index.html' 11 }), 12 new HtmlWebpackIncludeAssetsPlugin({ 13 files: ['a/**/*.html'], 14 assets: ['css/a.css'], 15 append: true 16 }), 17 new HtmlWebpackIncludeAssetsPlugin({ 18 files: ['b/**/*.html'], 19 assets: ['css/b.css'], 20 append: true 21 }) 22]
Specifying assets usings a glob
Note that since copy-webpack-plugin
does not actually copy the files to webpack's output directory until after html-webpack-plugin
has completed, it is necessary to use the globPath
to retrieve filename matches relative to the original location of any such files.
1plugins: [ 2 new CopyWebpackPlugin([ 3 { from: 'node_modules/bootstrap/dist/css', to: 'css/'}, 4 { from: 'node_modules/bootstrap/dist/fonts', to: 'fonts/'} 5 ]), 6 new HtmlWebpackPlugin(), 7 new HtmlWebpackIncludeAssetsPlugin({ 8 assets: [{ path: 'css', glob: '*.css', globPath: 'node_modules/bootstrap/dist/css/' }], 9 append: true 10 }) 11]
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/28 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
27 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-05-12
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreLast Day
0%
1
Compared to previous day
Last Week
-28.6%
5
Compared to previous week
Last Month
35%
27
Compared to previous month
Last Year
-10.3%
175
Compared to previous year