summaryrefslogtreecommitdiff
path: root/config/webpack.config.js
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-18 21:09:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-18 21:09:11 +0000
commit93d7441cc98c1db55797a2181a3d9f4b3d26d82c (patch)
tree72a7da7027a656239c2a40cfcef1db58238a2247 /config/webpack.config.js
parent6b8d671de726534a03c18e025a586e1bc9c04a4f (diff)
downloadgitlab-ce-93d7441cc98c1db55797a2181a3d9f4b3d26d82c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'config/webpack.config.js')
-rw-r--r--config/webpack.config.js64
1 files changed, 52 insertions, 12 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js
index 639de770fd8..05a217c04fe 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -117,23 +117,18 @@ 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.`);
- }
+ 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`,
+ exists: null,
+ };
}
module.exports = {
@@ -314,6 +309,51 @@ module.exports = {
jQuery: 'jquery',
}),
+ // if DLLs are enabled, detect whether the DLL exists and create it automatically if necessary
+ dll && {
+ apply(compiler) {
+ compiler.hooks.beforeCompile.tapAsync('DllAutoCompilePlugin', (params, callback) => {
+ if (dll.exists) {
+ callback();
+ } else if (fs.existsSync(dll.manifestPath)) {
+ console.log(`Using vendor DLL found at: ${dll.cacheFrom}`);
+ dll.exists = true;
+ callback();
+ } else {
+ console.log(
+ `Warning: No vendor DLL found at: ${dll.cacheFrom}. Compiling DLL automatically.`,
+ );
+
+ const dllConfig = require('./webpack.vendor.config.js');
+ const dllCompiler = webpack(dllConfig);
+
+ dllCompiler.run((err, stats) => {
+ if (err) {
+ return callback(err);
+ }
+
+ const info = stats.toJson();
+
+ if (stats.hasErrors()) {
+ console.error(info.errors.join('\n\n'));
+ return callback('DLL not compiled successfully.');
+ }
+
+ if (stats.hasWarnings()) {
+ console.warn(info.warnings.join('\n\n'));
+ console.warn('DLL compiled with warnings.');
+ } else {
+ console.log('DLL compiled successfully.');
+ }
+
+ dll.exists = true;
+ callback();
+ });
+ }
+ });
+ },
+ },
+
// reference our compiled DLL modules
dll &&
new webpack.DllReferencePlugin({