Commit ce6bc061 authored by Tim Zallmann's avatar Tim Zallmann

Merge branch '32737-audit-long-term-cacheability-of-webpack-assets' into 'master'

Resolve "Audit long-term cacheability of webpack assets"

Closes #32737

See merge request !11622
parents 8e2fefc6 643a10fc
...@@ -5,6 +5,7 @@ var path = require('path'); ...@@ -5,6 +5,7 @@ var path = require('path');
var webpack = require('webpack'); var webpack = require('webpack');
var StatsPlugin = require('stats-webpack-plugin'); var StatsPlugin = require('stats-webpack-plugin');
var CompressionPlugin = require('compression-webpack-plugin'); var CompressionPlugin = require('compression-webpack-plugin');
var NameAllModulesPlugin = require('name-all-modules-plugin');
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
...@@ -69,7 +70,8 @@ var config = { ...@@ -69,7 +70,8 @@ var config = {
output: { output: {
path: path.join(ROOT_PATH, 'public/assets/webpack'), path: path.join(ROOT_PATH, 'public/assets/webpack'),
publicPath: '/assets/webpack/', publicPath: '/assets/webpack/',
filename: IS_PRODUCTION ? '[name].[chunkhash].bundle.js' : '[name].bundle.js' filename: IS_PRODUCTION ? '[name].[chunkhash].bundle.js' : '[name].bundle.js',
chunkFilename: IS_PRODUCTION ? '[name].[chunkhash].chunk.js' : '[name].chunk.js',
}, },
devtool: 'cheap-module-source-map', devtool: 'cheap-module-source-map',
...@@ -126,8 +128,20 @@ var config = { ...@@ -126,8 +128,20 @@ var config = {
jQuery: 'jquery', jQuery: 'jquery',
}), }),
// use deterministic module ids // assign deterministic module ids
new webpack.NamedModulesPlugin(), new webpack.NamedModulesPlugin(),
new NameAllModulesPlugin(),
// assign deterministic chunk ids
new webpack.NamedChunksPlugin((chunk) => {
if (chunk.name) {
return chunk.name;
}
return chunk.modules.map((m) => {
var chunkPath = m.request.split('!').pop();
return path.relative(m.context, chunkPath);
}).join('_');
}),
// create cacheable common library bundle for all vue chunks // create cacheable common library bundle for all vue chunks
new webpack.optimize.CommonsChunkPlugin({ new webpack.optimize.CommonsChunkPlugin({
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
"jszip-utils": "^0.0.2", "jszip-utils": "^0.0.2",
"marked": "^0.3.6", "marked": "^0.3.6",
"mousetrap": "^1.4.6", "mousetrap": "^1.4.6",
"name-all-modules-plugin": "^1.0.1",
"pdfjs-dist": "^1.8.252", "pdfjs-dist": "^1.8.252",
"pikaday": "^1.5.1", "pikaday": "^1.5.1",
"prismjs": "^1.6.0", "prismjs": "^1.6.0",
...@@ -57,8 +58,8 @@ ...@@ -57,8 +58,8 @@
"vue-loader": "^11.3.4", "vue-loader": "^11.3.4",
"vue-resource": "^0.9.3", "vue-resource": "^0.9.3",
"vue-template-compiler": "^2.2.6", "vue-template-compiler": "^2.2.6",
"webpack": "^2.3.3", "webpack": "^2.6.1",
"webpack-bundle-analyzer": "^2.3.0" "webpack-bundle-analyzer": "^2.8.2"
}, },
"devDependencies": { "devDependencies": {
"babel-plugin-istanbul": "^4.0.0", "babel-plugin-istanbul": "^4.0.0",
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment