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:
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
|
-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',
|
||||||
|
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) {
|
if (opts.debug) {
|
||||||
config.stats = 'verbose'
|
config.stats = 'verbose'
|
||||||
// todo: enable other logging
|
// todo: enable other logging
|
||||||
|
@ -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"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user