Does webpack-dev-server supports bundle names with [hash] in file name?
I have the following setup:
module.exports = {
context: __dirname,
entry: './app/test.js',
output: {
filename: '[name].[hash].js',
path: path.join(__dirname, "dist"),
},
module: {
loaders: [{ test: /\.js$/, loader: 'babel', exclude: /node_modules/, query: { presets: ['es2015']}} ]
},
plugins: [new ExtractTextPlugin("[hash].css"), new AssetsWebpackPlugin()]
}
All assets generated correctly, but how can I reference it in my index.html? Js or css file name depends on [hash] value and changes with every build.
There is no need to use hash in webpack dev server, there is no cache problems.
It does work in webpack-dev-server, but it is not recommended. If you do this, on every incremental build the server will generate a new JS file with the hash in it. The old files will not be removed, so the process will slowly run out of memory.
I'm using this hack in my config:
const IS_DEV_SERVER = process.argv[1].indexOf('webpack-dev-server') >= 0;
module.exports = {
output: {
filename: `[name]-${IS_DEV_SERVER ? 'dev' : '[hash:7]'}.js`,
},
};
Most helpful comment
It does work in webpack-dev-server, but it is not recommended. If you do this, on every incremental build the server will generate a new JS file with the hash in it. The old files will not be removed, so the process will slowly run out of memory.
I'm using this hack in my config: