diff --git a/lib/builder/builder.mjs b/lib/builder/builder.mjs index 947efb1773..d4265907ab 100644 --- a/lib/builder/builder.mjs +++ b/lib/builder/builder.mjs @@ -534,15 +534,6 @@ export default class Builder { console.error(err) // eslint-disable-line no-console return reject(err) } - - if (!this.options.test) { - process.stdout.write( - '\n' + - stats.toString(this.options.build.stats) + - '\n' - ) - } - resolve() }) }) diff --git a/lib/builder/webpack/base.config.mjs b/lib/builder/webpack/base.config.mjs index 476a77c59a..81815319c0 100644 --- a/lib/builder/webpack/base.config.mjs +++ b/lib/builder/webpack/base.config.mjs @@ -4,14 +4,15 @@ import FriendlyErrorsWebpackPlugin from '@nuxtjs/friendly-errors-webpack-plugin' import TimeFixPlugin from 'time-fix-plugin' import webpack from 'webpack' import _ from 'lodash' - import VueLoader from 'vue-loader' + import { isUrl, urlJoin } from '../../common/utils' import customLoaders from './loaders' +import styleLoaderWrapper from './style-loader' import WarnFixPlugin from './plugins/warnfix' import ProgressPlugin from './plugins/progress' -import styleLoaderWrapper from './style-loader' +import StatsPlugin from './plugins/stats' /* |-------------------------------------------------------------------------- @@ -130,8 +131,16 @@ export default function webpackBaseConfig({ name, isServer }) { ].concat(this.options.build.plugins || []) } - // Build progress indicator + // Add timefix-plugin before others plugins + if (this.options.dev) { + config.plugins.unshift(new TimeFixPlugin()) + } + + // Hide warnings about plugins without a default export (#1179) + config.plugins.push(new WarnFixPlugin()) + if (!this.options.test) { + // Build progress indicator if (this.options.build.profile) { config.plugins.push(new webpack.ProgressPlugin({ profile: true })) } else { @@ -143,24 +152,19 @@ export default function webpackBaseConfig({ name, isServer }) { })) } } + + // Add stats plugin + config.plugins.push(new StatsPlugin(this.options.build.stats)) + + // Add friendly error plugin + config.plugins.push( + new FriendlyErrorsWebpackPlugin({ + clearConsole: true, + logLevel: 'WARNING' + }) + ) } - // Add timefix-plugin before others plugins - if (this.options.dev) { - config.plugins.unshift(new TimeFixPlugin()) - } - - // Hide warnings about plugins without a default export (#1179) - config.plugins.push(new WarnFixPlugin()) - - // Add friendly error plugin - config.plugins.push( - new FriendlyErrorsWebpackPlugin({ - clearConsole: true, - logLevel: 'WARNING' - }) - ) - // Clone deep avoid leaking config between Client and Server return _.cloneDeep(config) } diff --git a/lib/builder/webpack/plugins/stats.mjs b/lib/builder/webpack/plugins/stats.mjs new file mode 100644 index 0000000000..8377e9fd84 --- /dev/null +++ b/lib/builder/webpack/plugins/stats.mjs @@ -0,0 +1,16 @@ + +export default class StatsPlugin { + constructor(statsOptions) { + this.statsOptions = statsOptions + } + + apply(compiler) { + compiler.hooks.done.tap('stats-plugin', stats => { + process.stdout.write( + '\n' + + stats.toString(this.statsOptions) + + '\n' + ) + }) + } +}