1
0
mirror of https://github.com/flarum/core.git synced 2025-07-16 06:16:23 +02:00

Add Webpack Bundle Analyzer to webpack config (#12)

This commit is contained in:
David Wheatley
2021-05-13 00:05:27 +01:00
committed by GitHub
parent 30a95910bb
commit abea6716eb
4 changed files with 147 additions and 3 deletions

View File

@ -25,12 +25,21 @@ function getEntryPoints() {
return entries;
}
const useBundleAnalyzer = process.env.ANALYZER === 'true';
const plugins = [];
if (useBundleAnalyzer) {
plugins.push(new (require('webpack-bundle-analyzer').BundleAnalyzerPlugin)());
}
module.exports = function (options = {}) {
return {
// Set up entry points for each of the forum + admin apps, but only
// if they exist.
entry: getEntryPoints(),
plugins,
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
},
@ -91,8 +100,10 @@ module.exports = function (options = {}) {
if (options.useExtensions) {
for (const extension of options.useExtensions) {
externals['@' + extension] = externals['@' + extension + '/forum'] = externals['@' + extension + '/admin'] =
"flarum.extensions['" + extension + "']";
externals['@' + extension] =
externals['@' + extension + '/forum'] =
externals['@' + extension + '/admin'] =
"flarum.extensions['" + extension + "']";
}
}