diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-17 09:07:48 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-17 09:07:48 +0000 |
commit | 5bd24a54ef4ce3a38a860eb53b66d062c2382971 (patch) | |
tree | 5f5e65571dfcb2c62c27600ee7655dec4b44c923 /config/webpack.config.js | |
parent | 74673d04d25ffed35cbcf17cd42969bed0a4e705 (diff) | |
download | gitlab-ce-5bd24a54ef4ce3a38a860eb53b66d062c2382971.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'config/webpack.config.js')
-rw-r--r-- | config/webpack.config.js | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js index c0be2f66ca7..d85fa84c32f 100644 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -1,6 +1,6 @@ +const fs = require('fs'); const path = require('path'); const glob = require('glob'); -const fs = require('fs'); const webpack = require('webpack'); const VueLoaderPlugin = require('vue-loader/lib/plugin'); const StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin; @@ -8,8 +8,10 @@ const CompressionPlugin = require('compression-webpack-plugin'); const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const CopyWebpackPlugin = require('copy-webpack-plugin'); +const vendorDllHash = require('./helpers/vendor_dll_hash'); const ROOT_PATH = path.resolve(__dirname, '..'); +const VENDOR_DLL = process.env.WEBPACK_VENDOR_DLL && process.env.WEBPACK_VENDOR_DLL !== 'false'; const CACHE_PATH = process.env.WEBPACK_CACHE_PATH || path.join(ROOT_PATH, 'tmp/cache'); const IS_PRODUCTION = process.env.NODE_ENV === 'production'; const IS_DEV_SERVER = process.env.WEBPACK_DEV_SERVER === 'true'; @@ -113,6 +115,25 @@ if (IS_EE) { }); } +// if there is a compiled DLL with a matching hash string, use it +let dll; + +if (VENDOR_DLL && !IS_PRODUCTION) { + const dllHash = vendorDllHash(); + const dllCachePath = path.join(ROOT_PATH, `tmp/cache/webpack-dlls/${dllHash}`); + if (fs.existsSync(dllCachePath)) { + console.log(`Using vendor DLL found at: ${dllCachePath}`); + dll = { + manifestPath: path.join(dllCachePath, 'vendor.dll.manifest.json'), + cacheFrom: dllCachePath, + cacheTo: path.join(ROOT_PATH, `public/assets/webpack/dll.${dllHash}/`), + publicPath: `dll.${dllHash}/vendor.dll.bundle.js`, + }; + } else { + console.log(`Warning: No vendor DLL found at: ${dllCachePath}. DllPlugin disabled.`); + } +} + module.exports = { mode: IS_PRODUCTION ? 'production' : 'development', @@ -267,6 +288,11 @@ module.exports = { modules: false, assets: true, }); + + // tell our rails helper where to find the DLL files + if (dll) { + stats.dllAssets = dll.publicPath; + } return JSON.stringify(stats, null, 2); }, }), @@ -286,6 +312,21 @@ module.exports = { jQuery: 'jquery', }), + // reference our compiled DLL modules + dll && + new webpack.DllReferencePlugin({ + context: ROOT_PATH, + manifest: dll.manifestPath, + }), + + dll && + new CopyWebpackPlugin([ + { + from: dll.cacheFrom, + to: dll.cacheTo, + }, + ]), + !IS_EE && new webpack.NormalModuleReplacementPlugin(/^ee_component\/(.*)\.vue/, resource => { resource.request = path.join( |