Add webpack memory test to CI
This commit is contained in:
parent
70302281d7
commit
1c621da362
2 changed files with 39 additions and 0 deletions
|
@ -232,3 +232,17 @@ qa-frontend-node:latest:
|
|||
extends: .qa-frontend-node
|
||||
image: node:latest
|
||||
allow_failure: true
|
||||
|
||||
webpack-dev-server:
|
||||
extends:
|
||||
- .default-tags
|
||||
- .default-retry
|
||||
- .default-cache
|
||||
- .except-docs-qa
|
||||
dependencies: ["compile-assets", "compile-assets pull-cache", "setup-test-env"]
|
||||
variables:
|
||||
SETUP_DB: "false"
|
||||
WEBPACK_MEMORY_TEST: "true"
|
||||
script:
|
||||
- node --version
|
||||
- node --expose-gc node_modules/.bin/webpack-dev-server --config 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(),
|
||||
|
||||
|
|
Loading…
Reference in a new issue