summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2019-09-11 16:36:18 +0000
committerClement Ho <408677-ClemMakesApps@users.noreply.gitlab.com>2019-09-11 16:36:18 +0000
commit1c621da36250b18a4e3b9f76c748d69df9255f33 (patch)
tree168d6258d177037905d6be7026f7b96f6726f501 /config
parent70302281d70b65bd0653f9f3732e5dbbbbc98753 (diff)
downloadgitlab-ce-1c621da36250b18a4e3b9f76c748d69df9255f33.tar.gz
Add webpack memory test to CI
Diffstat (limited to 'config')
-rw-r--r--config/webpack.config.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/config/webpack.config.js b/config/webpack.config.js
index 969a84e85dd..f3f0a5f8934 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -17,6 +17,7 @@ const DEV_SERVER_HOST = process.env.DEV_SERVER_HOST || 'localhost';
const DEV_SERVER_PORT = parseInt(process.env.DEV_SERVER_PORT, 10) || 3808;
const DEV_SERVER_LIVERELOAD = IS_DEV_SERVER && process.env.DEV_SERVER_LIVERELOAD !== 'false';
const WEBPACK_REPORT = process.env.WEBPACK_REPORT;
+const WEBPACK_MEMORY_TEST = process.env.WEBPACK_MEMORY_TEST;
const NO_COMPRESSION = process.env.NO_COMPRESSION;
const NO_SOURCEMAPS = process.env.NO_SOURCEMAPS;
@@ -337,6 +338,30 @@ module.exports = {
},
},
+ // output the in-memory heap size upon compilation and exit
+ WEBPACK_MEMORY_TEST && {
+ apply(compiler) {
+ compiler.hooks.emit.tapAsync('ReportMemoryConsumptionPlugin', (compilation, callback) => {
+ console.log('Assets compiled...');
+ if (global.gc) {
+ console.log('Running garbage collection...');
+ global.gc();
+ } else {
+ console.error(
+ "WARNING: you must use the --expose-gc node option to accurately measure webpack's heap size",
+ );
+ }
+ const memoryUsage = process.memoryUsage().heapUsed;
+ const toMB = bytes => Math.floor(bytes / 1024 / 1024);
+
+ console.log(`Webpack heap size: ${toMB(memoryUsage)} MB`);
+
+ // exit in case we're running webpack-dev-server
+ IS_DEV_SERVER && process.exit();
+ });
+ },
+ },
+
// enable HMR only in webpack-dev-server
DEV_SERVER_LIVERELOAD && new webpack.HotModuleReplacementPlugin(),