diff --git a/cli.js b/cli.js index 9afa4ed..1e7ef10 100755 --- a/cli.js +++ b/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', diff --git a/lib/dev.js b/lib/dev.js index c72a387..7e2b964 100644 --- a/lib/dev.js +++ b/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 diff --git a/package.json b/package.json index 47dd9ae..7aa01dd 100644 --- a/package.json +++ b/package.json @@ -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" },