diff --git a/packages/nuxt3/src/builder/webpack/presets/base.ts b/packages/nuxt3/src/builder/webpack/presets/base.ts index 00e1a053d9..a7ac842a1d 100644 --- a/packages/nuxt3/src/builder/webpack/presets/base.ts +++ b/packages/nuxt3/src/builder/webpack/presets/base.ts @@ -1,8 +1,9 @@ import { resolve, normalize } from 'path' import TimeFixPlugin from 'time-fix-plugin' import WebpackBar from 'webpackbar' +import consola from 'consola' import { DefinePlugin, Configuration } from 'webpack' -// import FriendlyErrorsWebpackPlugin from '@nuxt/friendly-errors-webpack-plugin' +import FriendlyErrorsWebpackPlugin from '@nuxt/friendly-errors-webpack-plugin' import { isUrl, urlJoin, TARGETS } from 'src/utils' import escapeRegExp from 'lodash/escapeRegExp' import WarningIgnorePlugin from '../plugins/warning-ignore' @@ -33,7 +34,7 @@ function baseConfig (ctx: WebpackConfigContext) { mode: ctx.isDev ? 'development' : 'production', cache: getCache(ctx), output: getOutput(ctx), - stats: 'errors-warnings', + stats: 'none', ...ctx.config } } @@ -56,18 +57,18 @@ function basePlugins (ctx: WebpackConfigContext) { config.plugins.push(new DefinePlugin(getEnv(ctx))) // Friendly errors - // if ( - // ctx.isServer || - // (ctx.isDev && !options.build.quiet && options.build.friendlyErrors) - // ) { - // ctx.config.plugins.push( - // new FriendlyErrorsWebpackPlugin({ - // clearConsole: false, - // reporter: 'consola', - // logLevel: 'WARNING' - // }) - // ) - // } + if ( + ctx.isServer || + (ctx.isDev && !options.build.quiet && options.build.friendlyErrors) + ) { + ctx.config.plugins.push( + new FriendlyErrorsWebpackPlugin({ + clearConsole: false, + reporter: 'consola', + logLevel: 'ERROR' // TODO + }) + ) + } // Webpackbar const colors = { @@ -78,8 +79,7 @@ function basePlugins (ctx: WebpackConfigContext) { config.plugins.push(new WebpackBar({ name: ctx.name, color: colors[ctx.name], - reporters: ['basic', 'stats'], - basic: true, + reporters: ['stats'], stats: !ctx.isDev, reporter: { change: (_, { shortPath }) => { @@ -87,9 +87,11 @@ function basePlugins (ctx: WebpackConfigContext) { nuxt.callHook('bundler:change', shortPath) } }, - done: (stats) => { - if (stats.hasErrors) { + done: ({ state }) => { + if (state.hasErrors) { nuxt.callHook('bundler:error') + } else { + consola.success(`${state.name} ${state.message}`) } }, allDone: () => { diff --git a/packages/nuxt3/src/builder/webpack/webpack.ts b/packages/nuxt3/src/builder/webpack/webpack.ts index 1368430c16..d689128cb7 100644 --- a/packages/nuxt3/src/builder/webpack/webpack.ts +++ b/packages/nuxt3/src/builder/webpack/webpack.ts @@ -178,6 +178,7 @@ class WebpackBundler { compiler, { publicPath: buildOptions.publicPath, outputFileSystem: this.mfs, + stats: 'none', ...buildOptions.devMiddleware }) )