1
1
mirror of https://github.com/c8r/x0.git synced 2024-08-16 17:00:24 +03:00

Add bundle analyzer option

This commit is contained in:
Brent Jackson 2018-06-23 18:26:36 -04:00
parent db2ed22fd1
commit 05dce94908
3 changed files with 16 additions and 1 deletions

2
cli.js
View File

@ -34,6 +34,7 @@ const cli = meow(`
-o --open Open dev server in default browser -o --open Open dev server in default browser
-p --port Port for dev server -p --port Port for dev server
--analyze Runs with webpack-bundle-analyzer plugin
${chalk.gray('Build')} ${chalk.gray('Build')}
@ -52,6 +53,7 @@ const cli = meow(`
type: 'string', type: 'string',
alias: 'p' alias: 'p'
}, },
analyze: {},
// build // build
outDir: { outDir: {
type: 'string', type: 'string',

View File

@ -60,6 +60,18 @@ module.exports = async (opts) => {
}) })
) )
if (opts.analyze) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
const analyzerPort = typeof opts.analyze === 'string'
? opts.analyze
: 8888
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerPort
})
)
}
if (opts.debug) { if (opts.debug) {
config.stats = 'verbose' config.stats = 'verbose'
// todo: enable other logging // todo: enable other logging

View File

@ -7,7 +7,7 @@
"x0": "cli.js" "x0": "cli.js"
}, },
"scripts": { "scripts": {
"start": "./cli.js docs -p 8888", "start": "./cli.js docs -p 8989",
"build": "./cli.js build docs", "build": "./cli.js build docs",
"test": "nyc ava --timeout=60s", "test": "nyc ava --timeout=60s",
"test:components": "nyc ava test/components.js", "test:components": "nyc ava test/components.js",
@ -78,6 +78,7 @@
"styled-system": "^2.3.1", "styled-system": "^2.3.1",
"update-notifier": "^2.5.0", "update-notifier": "^2.5.0",
"webpack": "^4.10.2", "webpack": "^4.10.2",
"webpack-bundle-analyzer": "^2.13.1",
"webpack-merge": "^4.1.3", "webpack-merge": "^4.1.3",
"webpack-serve": "^1.0.4" "webpack-serve": "^1.0.4"
}, },