Gathering detailed insights and metrics for asset-injector-webpack-plugin
Gathering detailed insights and metrics for asset-injector-webpack-plugin
Gathering detailed insights and metrics for asset-injector-webpack-plugin
Gathering detailed insights and metrics for asset-injector-webpack-plugin
Simply inject CSS and JavaScript assets into HTML assets with Webpack
npm install asset-injector-webpack-plugin
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
8 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Mar 15, 2018
Latest Version
0.1.9
Package Id
asset-injector-webpack-plugin@0.1.9
Unpacked Size
11.41 kB
Size
3.81 kB
File Count
4
NPM Version
5.6.0
Node Version
8.10.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
No dependencies detected.
Asset Injector is a simple, lightweight way to put <link>
and <script>
tags where you want them in your HTML files. When such a basic task is what you need, something like HTML Webpack Plugin can be overkill and needlessly balloon your build time.
1$ npm install asset-injector-webpack-plugin --save-dev
Asset Injector replaces structured comments in HTML files with <link>
and/or <script>
tags that reference the compiled asset(s) for a given chunk name.
webpack.config.js
1... 2 3const asset_injector = require('asset-suppressor-webpack-plugin'); 4 5... 6 7webpack_config.entry = { 8 index: './index.js', 9 'index.css': './index.css', 10 'index.html': './index.html', 11 }; 12 13... 14 15const Commons_chunk = webpack.optimize.CommonsChunkPlugin; 16webpack_config.plugins = [ 17 new Commons_chunk({ name: 'lib', minChunks: is_from_npm }), 18 new Commons_chunk({ name: 'liaison', minChunks: Infinity }), // sometimes called "manifest" 19 asset_injector(), 20 ]; 21 22... 23 24function is_from_npm(module) { 25 return module.context && -1 !== module.context.indexOf('node_modules'); 26} 27 28...
index.html
1<html> 2<head> 3 <meta charset="utf-8"/> 4 <title>App</title> 5 <!-- asset-injector index.css --> 6 <!-- asset-injector liaison --> 7 <!-- asset-injector lib --> 8</head> 9<body> 10 <div id="app"></div> 11 <!-- asset-injector index --> 12</body> 13</html>
Because it is not always obvious what assets Webpack will output for a given chunk, Asset Injector seeks to be lenient while specific.
For the index.css
entry point in the earlier example, <!-- asset-injector index.css -->
will be replaced with something like:
1<script src="/3786e0d596e0453.js"></script><link rel="stylesheet" href="/3786e0d596e0453ebb5e29dbc2dbcc4a.css"/>
This is because all entry points result in a .js
file being output (and generally a .js.map
file too). To specify only the stylesheet, each of the following will only inject the <link>
tag:
1<!-- asset-injector style index.css --> 2<!-- asset-injector styles index.css --> 3<!-- asset-injector stylesheet index.css --> 4<!-- asset-injector-plugin style index.css --> 5<!-- asset-injector-webpack-plugin styles index.css --> 6<!-- asset_injector_webpack_plugin stylesheet index.css -->
The same is true for <script>
tags:
1<!-- asset-injector script lib --> 2<!-- asset-injector scripts lib -->
And because it is also not always obvious what Webpack chunks' names are, Asset Injector attempts to figure out what you intended if a chunk name isn't found. For example, simple mistakes like the following will do what you expect:
<!-- asset-injector lib.js -->
will work if the chunk name is technically lib
<!-- asset-injector styles.css -->
will work if the chunk name is technically styles.scss
(SASS file) or styles
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
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 0/8 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
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
Score
Last Scanned on 2025-07-07
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 More