Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Add bundleanalyzer config and webpack plugin #1381

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .bundle-analyzer.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
files: [
{
test: '*.js',
maxSize: '200 kB',
},
{
test: '*frontend*.js',
maxSize: '60 kB',
},
{
test: '*.css',
maxSize: '50kB',
},
{
test: 'vendors*.js',
maxSize: '350 kb',
},
],
};
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ jobs:
script:
- npm install
- npm run build:ci
- cat webpack-stats.json | ./node_modules/.bin/bundle-analyzer --token $BUNDLE_ANALYZER_TOKEN
6 changes: 4 additions & 2 deletions bin/webpack-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const getEntryConfig = ( main = true, exclude = [] ) => {

const getMainConfig = ( options = {} ) => {
let { fileSuffix } = options;
const { alias, resolvePlugins = [] } = options;
const { alias, resolvePlugins = [], mainPlugins = [] } = options;
fileSuffix = fileSuffix ? `-${ fileSuffix }` : '';
const resolve = alias
? {
Expand Down Expand Up @@ -255,6 +255,7 @@ const getMainConfig = ( options = {} ) => {
new MiniCssExtractPlugin( {
filename: `[name]${ fileSuffix }.css`,
} ),
...mainPlugins,
new MergeExtractFilesPlugin(
[
`build/editor${ fileSuffix }.js`,
Expand All @@ -281,7 +282,7 @@ const getMainConfig = ( options = {} ) => {

const getFrontConfig = ( options = {} ) => {
let { fileSuffix } = options;
const { alias, resolvePlugins = [] } = options;
const { alias, resolvePlugins = [], mainPlugins = [] } = options;
fileSuffix = fileSuffix ? `-${ fileSuffix }` : '';
const resolve = alias
? {
Expand Down Expand Up @@ -369,6 +370,7 @@ const getFrontConfig = ( options = {} ) => {
requestToExternal,
requestToHandle,
} ),
...mainPlugins,
],
resolve,
};
Expand Down
Loading