mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
misc: improve --generate option
static version will be generated and auto open + json stats
This commit is contained in:
parent
47281c2761
commit
b8d30d806a
@ -60,9 +60,11 @@ nuxt.hook('error', (_err, from) => Utils.fatalError(_err, from))
|
||||
|
||||
// Close function
|
||||
const close = () => {
|
||||
if (options.build.analyze === true) {
|
||||
return // Wait for user exit
|
||||
// In analyze mode wait for plugin opening the browser
|
||||
if (options.build.analyze === true && !(this.options.ci || this.options.test)) {
|
||||
return
|
||||
}
|
||||
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
|
@ -66,10 +66,18 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
|
||||
}
|
||||
|
||||
// Webpack Bundle Analyzer
|
||||
// https://github.com/webpack-contrib/webpack-bundle-analyzer
|
||||
if (!this.options.dev && this.options.build.analyze) {
|
||||
plugins.push(
|
||||
new BundleAnalyzer.BundleAnalyzerPlugin(Object.assign({}, this.options.build.analyze))
|
||||
)
|
||||
const statsDir = path.resolve(this.options.buildDir, 'stats')
|
||||
|
||||
plugins.push(new BundleAnalyzer.BundleAnalyzerPlugin(Object.assign({
|
||||
analyzerMode: 'static',
|
||||
defaultSizes: 'gzip',
|
||||
generateStatsFile: true,
|
||||
openAnalyzer: !(this.options.ci || this.options.test),
|
||||
reportFilename: path.resolve(statsDir, 'client.html'),
|
||||
statsFilename: path.resolve(statsDir, 'client.json')
|
||||
}, this.options.build.analyze)))
|
||||
}
|
||||
|
||||
return plugins
|
||||
|
Loading…
Reference in New Issue
Block a user