diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2018-01-03 14:51:32 +0100 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2018-01-04 22:22:01 +0100 |
commit | 6d1548f86922d2489fd601c725a9748e3e563216 (patch) | |
tree | 6ef77eb8da5658c06a496c2b333258d03bc02205 | |
parent | b1e1990ee263bcae73f0e55526a55cff66103220 (diff) | |
download | gitlab-ce-6d1548f86922d2489fd601c725a9748e3e563216.tar.gz |
Fix Webpack config for ConcatenatedModulewinh-webpack-concatenated-module
-rw-r--r-- | config/webpack.config.js | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js index 5f95255334c..95fa79990e2 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -1,5 +1,6 @@ 'use strict'; +var crypto = require('crypto'); var fs = require('fs'); var path = require('path'); var webpack = require('webpack'); @@ -179,15 +180,34 @@ var config = { if (chunk.name) { return chunk.name; } - return chunk.mapModules((m) => { + + const moduleNames = []; + + function collectModuleNames(m) { + // handle ConcatenatedModule which does not have resource nor context set + if (m.modules) { + m.modules.forEach(collectModuleNames); + return; + } + const pagesBase = path.join(ROOT_PATH, 'app/assets/javascripts/pages'); + if (m.resource.indexOf(pagesBase) === 0) { - return path.relative(pagesBase, m.resource) + moduleNames.push(path.relative(pagesBase, m.resource) .replace(/\/index\.[a-z]+$/, '') - .replace(/\//g, '__'); + .replace(/\//g, '__')); + } else { + moduleNames.push(path.relative(m.context, m.resource)); } - return path.relative(m.context, m.resource); - }).join('_'); + } + + chunk.forEachModule(collectModuleNames); + + const hash = crypto.createHash('sha256') + .update(moduleNames.join('_')) + .digest('hex'); + + return `${moduleNames[0]}-${hash.substr(0, 6)}`; }), // create cacheable common library bundle for all vue chunks |