Skip to content

Instantly share code, notes, and snippets.

@okonet
Last active September 19, 2016 22:31
Show Gist options
  • Save okonet/26b3ac27a605636f39aa to your computer and use it in GitHub Desktop.
Save okonet/26b3ac27a605636f39aa to your computer and use it in GitHub Desktop.
Long-term caching with webpack example
var path = require('path');
var webpack = require('webpack');
var ManifestPlugin = require('webpack-manifest-plugin');
var ChunkManifestPlugin = require('chunk-manifest-webpack-plugin');
var WebpackMd5Hash = require('webpack-md5-hash');
module.exports = {
entry: {
vendor: './src/vendor.js',
main: './src/index.js'
},
output: {
path: path.join(__dirname, 'build'),
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"
}),
new webpack.optimize.OccurenceOrderPlugin()
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment