Merge branch 'build-speedup' into 'develop'
Webpack: improve build performance Closes #732 See merge request soapbox-pub/soapbox-fe!716
This commit is contained in:
commit
c472fcdfff
6 changed files with 26 additions and 22 deletions
|
@ -26,7 +26,6 @@ module.exports = (api) => {
|
||||||
|
|
||||||
switch (env) {
|
switch (env) {
|
||||||
case 'production':
|
case 'production':
|
||||||
envOptions.debug = false;
|
|
||||||
config.plugins.push(...[
|
config.plugins.push(...[
|
||||||
'lodash',
|
'lodash',
|
||||||
[
|
[
|
||||||
|
@ -51,7 +50,6 @@ module.exports = (api) => {
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
case 'development':
|
case 'development':
|
||||||
envOptions.debug = true;
|
|
||||||
config.plugins.push(...[
|
config.plugins.push(...[
|
||||||
'@babel/transform-react-jsx-source',
|
'@babel/transform-react-jsx-source',
|
||||||
'@babel/transform-react-jsx-self',
|
'@babel/transform-react-jsx-self',
|
||||||
|
|
|
@ -132,6 +132,7 @@
|
||||||
"sass": "^1.20.3",
|
"sass": "^1.20.3",
|
||||||
"sass-loader": "^10.0.0",
|
"sass-loader": "^10.0.0",
|
||||||
"semver": "^7.3.2",
|
"semver": "^7.3.2",
|
||||||
|
"speed-measure-webpack-plugin": "^1.5.0",
|
||||||
"stringz": "^2.0.0",
|
"stringz": "^2.0.0",
|
||||||
"substring-trie": "^1.0.2",
|
"substring-trie": "^1.0.2",
|
||||||
"terser-webpack-plugin": "^4.2.3",
|
"terser-webpack-plugin": "^4.2.3",
|
||||||
|
|
|
@ -2,8 +2,11 @@
|
||||||
console.log('Running in development mode'); // eslint-disable-line no-console
|
console.log('Running in development mode'); // eslint-disable-line no-console
|
||||||
|
|
||||||
const { merge } = require('webpack-merge');
|
const { merge } = require('webpack-merge');
|
||||||
|
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
|
||||||
const sharedConfig = require('./shared');
|
const sharedConfig = require('./shared');
|
||||||
|
|
||||||
|
const smp = new SpeedMeasurePlugin();
|
||||||
|
|
||||||
const watchOptions = {};
|
const watchOptions = {};
|
||||||
|
|
||||||
const backendUrl = process.env.BACKEND_URL || 'http://localhost:4000';
|
const backendUrl = process.env.BACKEND_URL || 'http://localhost:4000';
|
||||||
|
@ -48,7 +51,7 @@ if (process.env.VAGRANT) {
|
||||||
watchOptions.poll = 1000;
|
watchOptions.poll = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = merge(sharedConfig, {
|
module.exports = smp.wrap(merge(sharedConfig, {
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
cache: true,
|
cache: true,
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
|
@ -80,12 +83,7 @@ module.exports = merge(sharedConfig, {
|
||||||
'Access-Control-Allow-Origin': '*',
|
'Access-Control-Allow-Origin': '*',
|
||||||
},
|
},
|
||||||
overlay: true,
|
overlay: true,
|
||||||
stats: {
|
stats: 'errors-warnings',
|
||||||
entrypoints: false,
|
|
||||||
errorDetails: false,
|
|
||||||
modules: false,
|
|
||||||
moduleTrace: false,
|
|
||||||
},
|
|
||||||
watchOptions: Object.assign(
|
watchOptions: Object.assign(
|
||||||
{},
|
{},
|
||||||
{ ignored: '**/node_modules/**' },
|
{ ignored: '**/node_modules/**' },
|
||||||
|
@ -94,4 +92,4 @@ module.exports = merge(sharedConfig, {
|
||||||
serveIndex: true,
|
serveIndex: true,
|
||||||
proxy: makeProxyConfig(),
|
proxy: makeProxyConfig(),
|
||||||
},
|
},
|
||||||
});
|
}));
|
||||||
|
|
|
@ -6,13 +6,15 @@ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||||
const OfflinePlugin = require('offline-plugin');
|
const OfflinePlugin = require('offline-plugin');
|
||||||
const TerserPlugin = require('terser-webpack-plugin');
|
const TerserPlugin = require('terser-webpack-plugin');
|
||||||
const CompressionPlugin = require('compression-webpack-plugin');
|
const CompressionPlugin = require('compression-webpack-plugin');
|
||||||
|
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
|
||||||
const sharedConfig = require('./shared');
|
const sharedConfig = require('./shared');
|
||||||
|
|
||||||
module.exports = merge(sharedConfig, {
|
const smp = new SpeedMeasurePlugin();
|
||||||
|
|
||||||
|
module.exports = smp.wrap(merge(sharedConfig, {
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
stats: 'normal',
|
stats: 'errors-warnings',
|
||||||
bail: true,
|
bail: true,
|
||||||
optimization: {
|
optimization: {
|
||||||
minimize: true,
|
minimize: true,
|
||||||
|
@ -97,4 +99,4 @@ module.exports = merge(sharedConfig, {
|
||||||
// },
|
// },
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
}));
|
||||||
|
|
|
@ -68,13 +68,6 @@ module.exports = {
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
|
new webpack.EnvironmentPlugin(JSON.parse(JSON.stringify(env))),
|
||||||
new webpack.NormalModuleReplacementPlugin(
|
|
||||||
/^history\//, (resource) => {
|
|
||||||
// temporary fix for https://github.com/ReactTraining/react-router/issues/5576
|
|
||||||
// to reduce bundle size
|
|
||||||
resource.request = resource.request.replace(/^history/, 'history/es');
|
|
||||||
},
|
|
||||||
),
|
|
||||||
new MiniCssExtractPlugin({
|
new MiniCssExtractPlugin({
|
||||||
filename: 'packs/css/[name]-[contenthash:8].css',
|
filename: 'packs/css/[name]-[contenthash:8].css',
|
||||||
chunkFilename: 'packs/css/[name]-[contenthash:8].chunk.css',
|
chunkFilename: 'packs/css/[name]-[contenthash:8].chunk.css',
|
||||||
|
@ -89,7 +82,12 @@ module.exports = {
|
||||||
new UnusedFilesWebpackPlugin({
|
new UnusedFilesWebpackPlugin({
|
||||||
patterns: ['app/**/*.*'],
|
patterns: ['app/**/*.*'],
|
||||||
globOptions: {
|
globOptions: {
|
||||||
ignore: ['node_modules/**/*', '**/__*__/**/*'],
|
ignore: [
|
||||||
|
'node_modules/**/*',
|
||||||
|
'**/__*__/**/*',
|
||||||
|
'app/instance/about.example',
|
||||||
|
'app/soapbox/locales/whitelist_*.json',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
// https://github.com/jantimon/html-webpack-plugin#options
|
// https://github.com/jantimon/html-webpack-plugin#options
|
||||||
|
|
|
@ -11536,6 +11536,13 @@ specificity@^0.4.1:
|
||||||
resolved "https://registry.yarnpkg.com/specificity/-/specificity-0.4.1.tgz#aab5e645012db08ba182e151165738d00887b019"
|
resolved "https://registry.yarnpkg.com/specificity/-/specificity-0.4.1.tgz#aab5e645012db08ba182e151165738d00887b019"
|
||||||
integrity sha512-1klA3Gi5PD1Wv9Q0wUoOQN1IWAuPu0D1U03ThXTr0cJ20+/iq2tHSDnK7Kk/0LXJ1ztUB2/1Os0wKmfyNgUQfg==
|
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:
|
split-string@^3.0.1, split-string@^3.0.2:
|
||||||
version "3.1.0"
|
version "3.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
|
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
|
||||||
|
|
Loading…
Reference in a new issue