mirror of
https://github.com/c8r/x0.git
synced 2024-08-16 08:50:29 +03:00
Add bundle analyzer option
This commit is contained in:
parent
db2ed22fd1
commit
05dce94908
2
cli.js
2
cli.js
@ -34,6 +34,7 @@ const cli = meow(`
|
||||
|
||||
-o --open Open dev server in default browser
|
||||
-p --port Port for dev server
|
||||
--analyze Runs with webpack-bundle-analyzer plugin
|
||||
|
||||
${chalk.gray('Build')}
|
||||
|
||||
@ -52,6 +53,7 @@ const cli = meow(`
|
||||
type: 'string',
|
||||
alias: 'p'
|
||||
},
|
||||
analyze: {},
|
||||
// build
|
||||
outDir: {
|
||||
type: 'string',
|
||||
|
12
lib/dev.js
12
lib/dev.js
@ -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) {
|
||||
config.stats = 'verbose'
|
||||
// todo: enable other logging
|
||||
|
@ -7,7 +7,7 @@
|
||||
"x0": "cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "./cli.js docs -p 8888",
|
||||
"start": "./cli.js docs -p 8989",
|
||||
"build": "./cli.js build docs",
|
||||
"test": "nyc ava --timeout=60s",
|
||||
"test:components": "nyc ava test/components.js",
|
||||
@ -78,6 +78,7 @@
|
||||
"styled-system": "^2.3.1",
|
||||
"update-notifier": "^2.5.0",
|
||||
"webpack": "^4.10.2",
|
||||
"webpack-bundle-analyzer": "^2.13.1",
|
||||
"webpack-merge": "^4.1.3",
|
||||
"webpack-serve": "^1.0.4"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user