I have use require.ensure
to generator async chunk files like:
require.ensure([],function(require){
let Page1 = require('./page-1');
let Page2 = require('./page-2');
//...
},'page-chunk')
When I want to refresh the broswer cache after I changed code and rebuild, I use chunkhash
at config file and make chunks have a new flie name:
output: {
//...
chunkFilename: outputDir + "/[id].[name]-[chunkhash].js"
},
But it has ouccr too many files over and over again. and I often need to delete old files both local and server(also maybe it is unsafe):
QUESTION: Is there any way I can use query string for chunk files? I mean, for example :
require.ensure([],function(require){
let Page1 = require('./page-1');
let Page2 = require('./page-2');
//...
},'page-chunk', '?ver=[chunkhash]')
Then request should append search string when fetch the script like it:
http://cdn.com/path/output/1.page-chunk.js?ver=c5434xxxxxxx
Anyone have any experience on this? Thanks and looking forward to your help.
app.js?1234
andchunk1.js?1234
chunk2.js?1234
chunk2.js?1234
(loaded after the update) isn’t consistent withapp.js?1234
(loaded before the update), becausechunk2.js
was overwritten by your update and is nowchunk2.js?5678
.