【发布时间】:2018-05-25 15:04:23
【问题描述】:
我有一个非常大的项目,它使用两个 webpack 包来支持网站的旧版本和新版本。一个配置使用原始加载器来处理 html 文件。它看起来像这样:
this.configModern = {
entry: 'modern',
output: {
filename: 'bundled-[name].[chunkhash].js',
path: path.join(__dirname, '/Scripts/bundled/')
},
module: {
rules: [
{
test: /\.html$/,
use: [
'raw-loader'
]
},
]
},
plugins: [
new CommonsChunkPlugin({
name: 'vendor-modern',
minChunks: function (module) {
return module.context
&& module.context.includes('node_modules');
}
}),
new webpack.ProvidePlugin({
'window.jQuery': 'jquery'
}),
new HtmlWebpackPlugin({
filename: 'bundle_modern_dev.html',
template: './Views/Shared/WebpackTemplates/devTemplate.html',
inject: false,
}),
],
};
这是我的devTemplate.html
<% for (var js in htmlWebpackPlugin.files.js) { %>
<script src="/Scripts/bundled/<%= htmlWebpackPlugin.files.js[js] %>"></script>
<% } %>
我的问题是 raw-loader 导致 webpack 将我的 devTemplate.html 的内容复制到输出文件。
如何排除模板文件,以便它使用 html-webpack-plugin 的默认 ejs 加载器,而不使用 raw-loader。
编辑:
webpack 是 2.3.1 版
html-webpack-plugin 是 3.2.0 版本
【问题讨论】:
标签: javascript html webpack html-webpack-plugin