Skip to content

Commit

Permalink
Webpack: add SpeedMeasurePlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgleason committed Sep 4, 2021
1 parent 73baa1f commit 9700dee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"sass": "^1.20.3",
"sass-loader": "^10.0.0",
"semver": "^7.3.2",
"speed-measure-webpack-plugin": "^1.5.0",
"stringz": "^2.0.0",
"substring-trie": "^1.0.2",
"terser-webpack-plugin": "^4.2.3",
Expand Down
7 changes: 5 additions & 2 deletions webpack/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
console.log('Running in development mode'); // eslint-disable-line no-console

const { merge } = require('webpack-merge');
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
const sharedConfig = require('./shared');

const smp = new SpeedMeasurePlugin();

const watchOptions = {};

const backendUrl = process.env.BACKEND_URL || 'http://localhost:4000';
Expand Down Expand Up @@ -48,7 +51,7 @@ if (process.env.VAGRANT) {
watchOptions.poll = 1000;
}

module.exports = merge(sharedConfig, {
module.exports = smp.wrap(merge(sharedConfig, {
mode: 'development',
cache: true,
devtool: 'source-map',
Expand Down Expand Up @@ -94,4 +97,4 @@ module.exports = merge(sharedConfig, {
serveIndex: true,
proxy: makeProxyConfig(),
},
});
}));
8 changes: 5 additions & 3 deletions webpack/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const OfflinePlugin = require('offline-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');

const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
const sharedConfig = require('./shared');

module.exports = merge(sharedConfig, {
const smp = new SpeedMeasurePlugin();

module.exports = smp.wrap(merge(sharedConfig, {
mode: 'production',
devtool: 'source-map',
stats: 'normal',
Expand Down Expand Up @@ -97,4 +99,4 @@ module.exports = merge(sharedConfig, {
// },
}),
],
});
}));
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11536,6 +11536,13 @@ specificity@^0.4.1:
resolved "https://registry.yarnpkg.com/specificity/-/specificity-0.4.1.tgz#aab5e645012db08ba182e151165738d00887b019"
integrity sha512-1klA3Gi5PD1Wv9Q0wUoOQN1IWAuPu0D1U03ThXTr0cJ20+/iq2tHSDnK7Kk/0LXJ1ztUB2/1Os0wKmfyNgUQfg==

speed-measure-webpack-plugin@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/speed-measure-webpack-plugin/-/speed-measure-webpack-plugin-1.5.0.tgz#caf2c5bee24ab66c1c7c30e8daa7910497f7681a"
integrity sha512-Re0wX5CtM6gW7bZA64ONOfEPEhwbiSF/vz6e2GvadjuaPrQcHTQdRGsD8+BE7iUOysXH8tIenkPCQBEcspXsNg==
dependencies:
chalk "^4.1.0"

split-string@^3.0.1, split-string@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
Expand Down

0 comments on commit 9700dee

Please sign in to comment.