以下是webpack配置条目:
entry:{
background: './app/main/background.js',
options: './app/main/options.js'
}一个HTML页面,如下所示,与htmlwebpackplugin相匹配
new HtmlWebpackPlugin({
template :'./app/templates/options.html',
// chunks : ['jquery','angular','app'],
filename: "./options.html",
cache : true
}),这导致在background.js页面中注入options.html和options.js,如下所示:
<script type="text/javascript" src="js/background.js"></script><script type="text/javascript" src="js/options.js"></script></body>是否有方法将其限制为一个JS文件或指定要注入到html页面中的文件名?
发布于 2018-06-13 06:28:57
看来你可以用html-webpack-排除-资产-插件
plugins: [
new HtmlWebpackPlugin({
excludeAssets: [/style.*.js/] // exclude style.js or style.[chunkhash].js
}),
new HtmlWebpackExcludeAssetsPlugin()
] 发布于 2020-01-23 10:36:21
chunks选项可能是您想要使用的(请参阅文档的过滤块段 )。我不知道为什么它会在你的片段中被评论,但是你可以这样写:
entry: {
background: './app/main/background.js',
options: './app/main/options.js'
}如果只想在生成的options中注入HTML,请指定块:
new HtmlWebpackPlugin({
template :'./app/templates/options.html',
chunks : ['options'],
filename: "./options.html",
cache : true
}),https://stackoverflow.com/questions/50825549
复制相似问题