mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
refactor: add build.quiet config
This commit is contained in:
parent
141a54a1e3
commit
b60c4fd432
@ -51,8 +51,7 @@ if (argv.analyze && typeof options.build.analyze !== 'object') {
|
||||
|
||||
// Silence output when using --quiet
|
||||
if (argv.quiet) {
|
||||
options.test = true
|
||||
consola.level = 0
|
||||
options.build.quiet = !!argv.quiet
|
||||
}
|
||||
|
||||
const nuxt = new Nuxt(options)
|
||||
|
@ -532,7 +532,7 @@ export default class Builder {
|
||||
if (err) {
|
||||
return reject(err)
|
||||
} else if (stats.hasErrors()) {
|
||||
if (this.options.test) {
|
||||
if (this.options.build.quiet === true) {
|
||||
err = stats.toString(this.options.build.stats)
|
||||
}
|
||||
if (!err) {
|
||||
|
@ -66,7 +66,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
|
||||
analyzerMode: 'static',
|
||||
defaultSizes: 'gzip',
|
||||
generateStatsFile: true,
|
||||
openAnalyzer: !this.options.test,
|
||||
openAnalyzer: !this.options.build.quiet,
|
||||
reportFilename: path.resolve(statsDir, 'client.html'),
|
||||
statsFilename: path.resolve(statsDir, 'client.json')
|
||||
}, this.options.build.analyze)))
|
||||
@ -110,7 +110,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
|
||||
}
|
||||
|
||||
// Add friendly error plugin
|
||||
if (this.options.dev && !this.options.test) {
|
||||
if (this.options.dev && !this.options.build.quiet) {
|
||||
config.plugins.push(
|
||||
new FriendlyErrorsWebpackPlugin({
|
||||
clearConsole: true,
|
||||
|
@ -10,7 +10,6 @@ export default {
|
||||
// Information about running environment
|
||||
dev: Boolean(env.dev),
|
||||
debug: undefined, // = dev
|
||||
test: Boolean(env.ci || env.test),
|
||||
|
||||
// Mode
|
||||
mode: 'universal',
|
||||
@ -31,6 +30,7 @@ export default {
|
||||
extensions: [],
|
||||
|
||||
build: {
|
||||
quiet: Boolean(env.ci || env.test),
|
||||
analyze: false,
|
||||
profile: process.argv.includes('--profile'),
|
||||
extractCSS: false,
|
||||
|
@ -190,7 +190,11 @@ Options.from = function (_options) {
|
||||
options.build.optimization.splitChunks.name = true
|
||||
}
|
||||
|
||||
if (options.build.stats === 'none' || options.test === true) {
|
||||
if (options.build.quiet === true) {
|
||||
consola.clear().add({log: () => {}})
|
||||
}
|
||||
|
||||
if (options.build.stats === 'none' || options.build.quiet === true) {
|
||||
options.build.stats = false
|
||||
}
|
||||
|
||||
|
6
test/fixtures/cli/cli.build.config.js
vendored
6
test/fixtures/cli/cli.build.config.js
vendored
@ -1,12 +1,10 @@
|
||||
import consola from 'consola'
|
||||
|
||||
export default {
|
||||
hooks(hook) {
|
||||
hook('build:done', () => {
|
||||
consola.success('Compiled successfully')
|
||||
process.stdout.write('Compiled successfully')
|
||||
})
|
||||
hook('listen', (server, { port, host }) => {
|
||||
consola.success(`Listening on http://${host}:${port}`)
|
||||
process.stdout.write(`Listening on http://${host}:${port}`)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
6
test/fixtures/cli/cli.gen.config.js
vendored
6
test/fixtures/cli/cli.gen.config.js
vendored
@ -1,5 +1,3 @@
|
||||
import consola from 'consola'
|
||||
|
||||
export default {
|
||||
buildDir: '.nuxt-generate/.build',
|
||||
generate: {
|
||||
@ -8,9 +6,9 @@ export default {
|
||||
hooks(hook) {
|
||||
hook('generate:done', (generator, errors) => {
|
||||
if (!errors || errors.length === 0) {
|
||||
consola.success('Generated successfully')
|
||||
process.stdout.write('Generated successfully')
|
||||
} else {
|
||||
consola.error('Generated failed')
|
||||
process.stderr.write('Generated failed')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user