Css Webpack 2包含独立版本的html文件
我想设置一个包含两个html文件的项目:Css Webpack 2包含独立版本的html文件,css,iframe,webpack,bundle,webpack-4,Css,Iframe,Webpack,Bundle,Webpack 4,我想设置一个包含两个html文件的项目:index.html和iframe.html index.html应该注入来自index.js文件的捆绑包,但是对于iframe.html我想注入来自iframe.js文件中包含的依赖项的捆绑包 我有两个入口点的网页包(通用)配置: entry: { app: Path.resolve(__dirname, '../src/scripts/index.js'), iframe: Path.resolve(__dirname, '../src/scrip
index.html
和iframe.html
index.html
应该注入来自index.js
文件的捆绑包,但是对于iframe.html
我想注入来自iframe.js
文件中包含的依赖项的捆绑包
我有两个入口点的网页包(通用)配置:
entry: {
app: Path.resolve(__dirname, '../src/scripts/index.js'),
iframe: Path.resolve(__dirname, '../src/scripts/iframe.js')
},
output: {
path: Path.join(__dirname, '../build'),
filename: 'js/[name].js'
},
但似乎这两个html
文件都被注入了完整的捆绑包-我如何分割它?(并确保index.js
不会包含/共享iframe.js
文件中的代码?感谢我找到了一个解决方案:
new HtmlWebpackPlugin({
filename: 'index.html',
template: Path.resolve(__dirname, '../src/index.html'),
chunks: ['app']
}),
new HtmlWebpackPlugin({
filename: 'iframe.html',
template: Path.resolve(__dirname, '../src/iframe.html'),
chunks: ['iframe']
})