i came across following in webpack docs:
{ output: { path: path.join(__dirname, "assets", "[hash]"), publicpath: "assets/[hash]/", filename: "output.[hash].bundle.js", chunkfilename: "[id].[hash].bundle.js" } }
what point/purpose of adding hash file names? docs talk alot how it, not why. scenarios in beneficial?
the reason cache busting / invalidation. people use query string (?somehash
), doesn't work chunk splitting, while hash in filename does. see https://github.com/webpack/docs/wiki/long-term-caching overview.
note [chunkhash]
cannot used on entry chunk if use require.ensure
(or system.import
in webpack 2)*; need separate "chunk manifest" entry chunk using chunk-manifest-webpack-plugin
or inline-manifest-webpack-plugin
.
*: in webpack 1, [chunkhash]
cause entry chunk change if of "child chunks" changes unless split manifest out. in webpack 2, it'll compile time error.
Comments
Post a Comment