mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-07 09:22:27 +00:00
refactor: move stats to stats plugin
UX: warns from friendly error now come after stats
This commit is contained in:
parent
de847a7cd0
commit
fd9672e51d
@ -534,15 +534,6 @@ export default class Builder {
|
|||||||
console.error(err) // eslint-disable-line no-console
|
console.error(err) // eslint-disable-line no-console
|
||||||
return reject(err)
|
return reject(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.options.test) {
|
|
||||||
process.stdout.write(
|
|
||||||
'\n' +
|
|
||||||
stats.toString(this.options.build.stats) +
|
|
||||||
'\n'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -4,14 +4,15 @@ import FriendlyErrorsWebpackPlugin from '@nuxtjs/friendly-errors-webpack-plugin'
|
|||||||
import TimeFixPlugin from 'time-fix-plugin'
|
import TimeFixPlugin from 'time-fix-plugin'
|
||||||
import webpack from 'webpack'
|
import webpack from 'webpack'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
|
||||||
import VueLoader from 'vue-loader'
|
import VueLoader from 'vue-loader'
|
||||||
|
|
||||||
import { isUrl, urlJoin } from '../../common/utils'
|
import { isUrl, urlJoin } from '../../common/utils'
|
||||||
|
|
||||||
import customLoaders from './loaders'
|
import customLoaders from './loaders'
|
||||||
|
import styleLoaderWrapper from './style-loader'
|
||||||
import WarnFixPlugin from './plugins/warnfix'
|
import WarnFixPlugin from './plugins/warnfix'
|
||||||
import ProgressPlugin from './plugins/progress'
|
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 || [])
|
].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) {
|
if (!this.options.test) {
|
||||||
|
// Build progress indicator
|
||||||
if (this.options.build.profile) {
|
if (this.options.build.profile) {
|
||||||
config.plugins.push(new webpack.ProgressPlugin({ profile: true }))
|
config.plugins.push(new webpack.ProgressPlugin({ profile: true }))
|
||||||
} else {
|
} 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
|
// Clone deep avoid leaking config between Client and Server
|
||||||
return _.cloneDeep(config)
|
return _.cloneDeep(config)
|
||||||
}
|
}
|
||||||
|
16
lib/builder/webpack/plugins/stats.mjs
Normal file
16
lib/builder/webpack/plugins/stats.mjs
Normal file
@ -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'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user