You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
how to config webpack to package vendor to random file name? #1248
Now I see the file name remains unchanged if only main script has been edited.
However I see cloudflare/browser cache is causing issues, I do not know why. Maybe file remains the same but content is different?
I'm thinking to change to random file name anyway so that no cache will be used.
As far as I remember in production build vendor name is appended file hash, so that should help in that case. Dev builds should not be run on productions, as they lack the glory of tree shaking and uglification.
This behavior is produced by WebpackMd5Hash plugin.
@naivefun - There are quite a few ways to implement cache busting. I personally roll with something like this but I also have a moderately complex caching setup between my app, docker containers & nginx.
entry: {
'polyfills': './src/polyfills.browser.ts',
'vendor': './src/vendor.browser.ts',
'main': './src/main.browser.ts'
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].[chunkhash].js',
chunkFilename: '[name].[chunkhash].js'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
minChunks: Infinity,
}),
new WebpackMd5Hash(),
new ManifestPlugin(),
new ChunkManifestPlugin({
filename: "chunk-manifest.json",
manifestVariable: "webpackManifest"
})
]
Point being, this is one of those things that is really dependent on exactly what you are trying to achieve and how you are setup. Any way it goes, you will need WebpackMd5Hash as @karolmie1 mentioned.
It's also worth noting that what I run in production isn't based off the starter, so just grabbing that snippet isn't going to work ( just an example ).
I highly suggest reading https://webpack.js.org/guides/caching/ more than once and then start hacking on your project. Caching is one of those things you can get "kind of right" and end up with weird results.
You are going to want to understand your own caching implementation completely as it pertains to your app & the deployment stack it is running on. Docs + Trial and error is the best way to get there imo.
Activity
karolmie1 commentedon Dec 9, 2016
As far as I remember in production build vendor name is appended file hash, so that should help in that case. Dev builds should not be run on productions, as they lack the glory of tree shaking and uglification.
This behavior is produced by WebpackMd5Hash plugin.
joshwiens commentedon Dec 9, 2016
@naivefun - There are quite a few ways to implement cache busting. I personally roll with something like this but I also have a moderately complex caching setup between my app, docker containers & nginx.
Point being, this is one of those things that is really dependent on exactly what you are trying to achieve and how you are setup. Any way it goes, you will need
WebpackMd5Hashas @karolmie1 mentioned.It's also worth noting that what I run in production isn't based off the starter, so just grabbing that snippet isn't going to work ( just an example ).
I highly suggest reading https://webpack.js.org/guides/caching/ more than once and then start hacking on your project. Caching is one of those things you can get "kind of right" and end up with weird results.
You are going to want to understand your own caching implementation completely as it pertains to your app & the deployment stack it is running on. Docs + Trial and error is the best way to get there imo.
karolmie1 commentedon Jul 28, 2017
@naivefun Can this be closed?