webpack 创建bundle并替换字符串



我目前的 webpack-3 confing 从许多 angular-1 模块创建捆绑.js。

加载.js通过require加载捆绑包.js?1234.js我需要每次重建更改URL查询参数(防止缓存(。

我尝试了字符串替换加载器,但它不适用于简单的配置。由于加载.js不在入口文件列表中。

那么如何处理文件但不将其包含在捆绑包中呢?

module.exports = {
context: "/app",
entry: ['source1.js', 'source2.js', 'source3.js'],
output: {
path: "/dist",
filename: "bundle.js"
},
plugins: [ new BabiliPlugin() ],
module: {
loaders: [
{
test: /load.js$/,
loader: 'string-replace-loader',
query: {
search: 'bundle.js', // simple test, check it actually run
replace: '-replaced-'
}
}
]}};

你只需要做:

filename: "[name].[hash].bundle.js"

最新更新