diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-05-26 09:08:53 +0000 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2017-05-26 09:08:53 +0000 |
commit | ce6bc061b1375e85a984887606eccb506b1c44f9 (patch) | |
tree | 8fad9e1761753a76f773452237368cf8c449930a /config | |
parent | 8e2fefc6c44fc3c6140e5cbc4b56c58c90dc07f3 (diff) | |
parent | 643a10fcc890293d70f18188125c2e59d4d64d6d (diff) | |
download | gitlab-ce-ce6bc061b1375e85a984887606eccb506b1c44f9.tar.gz |
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
Diffstat (limited to 'config')
-rw-r--r-- | config/webpack.config.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js index 42024739fe9..2ada74e5a55 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -5,6 +5,7 @@ var path = require('path'); var webpack = require('webpack'); var StatsPlugin = require('stats-webpack-plugin'); var CompressionPlugin = require('compression-webpack-plugin'); +var NameAllModulesPlugin = require('name-all-modules-plugin'); var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); @@ -69,7 +70,8 @@ var config = { output: { path: path.join(ROOT_PATH, 'public/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', @@ -126,8 +128,20 @@ var config = { jQuery: 'jquery', }), - // use deterministic module ids + // assign deterministic module ids 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 new webpack.optimize.CommonsChunkPlugin({ |