Below are the webpack config entries :
entry:{
background: './app/main/background.js',
options: './app/main/options.js'
}
One HTML page which is suplied to htmlwebpackplugin as below
new HtmlWebpackPlugin({
template :'./app/templates/options.html',
// chunks : ['jquery','angular','app'],
filename: "./options.html",
cache : true
}),
This results in injecting both background.js
, options.js
in the options.html
page as below:
<script type="text/javascript" src="js/background.js"></script><script type="text/javascript" src="js/options.js"></script></body>
Is there a way to restrict it to only one JS file or specify the file names to be injected in html page?
Seems you can use html-webpack-exclude-assets-plugin
plugins: [
new HtmlWebpackPlugin({
excludeAssets: [/style.*.js/] // exclude style.js or style.[chunkhash].js
}),
new HtmlWebpackExcludeAssetsPlugin()
]