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
|
// Silence output when using --quiet
|
||||||
if (argv.quiet) {
|
if (argv.quiet) {
|
||||||
options.test = true
|
options.build.quiet = !!argv.quiet
|
||||||
consola.level = 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const nuxt = new Nuxt(options)
|
const nuxt = new Nuxt(options)
|
||||||
|
@ -532,7 +532,7 @@ export default class Builder {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return reject(err)
|
return reject(err)
|
||||||
} else if (stats.hasErrors()) {
|
} else if (stats.hasErrors()) {
|
||||||
if (this.options.test) {
|
if (this.options.build.quiet === true) {
|
||||||
err = stats.toString(this.options.build.stats)
|
err = stats.toString(this.options.build.stats)
|
||||||
}
|
}
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
@ -66,7 +66,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
|
|||||||
analyzerMode: 'static',
|
analyzerMode: 'static',
|
||||||
defaultSizes: 'gzip',
|
defaultSizes: 'gzip',
|
||||||
generateStatsFile: true,
|
generateStatsFile: true,
|
||||||
openAnalyzer: !this.options.test,
|
openAnalyzer: !this.options.build.quiet,
|
||||||
reportFilename: path.resolve(statsDir, 'client.html'),
|
reportFilename: path.resolve(statsDir, 'client.html'),
|
||||||
statsFilename: path.resolve(statsDir, 'client.json')
|
statsFilename: path.resolve(statsDir, 'client.json')
|
||||||
}, this.options.build.analyze)))
|
}, this.options.build.analyze)))
|
||||||
@ -110,7 +110,7 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add friendly error plugin
|
// Add friendly error plugin
|
||||||
if (this.options.dev && !this.options.test) {
|
if (this.options.dev && !this.options.build.quiet) {
|
||||||
config.plugins.push(
|
config.plugins.push(
|
||||||
new FriendlyErrorsWebpackPlugin({
|
new FriendlyErrorsWebpackPlugin({
|
||||||
clearConsole: true,
|
clearConsole: true,
|
||||||
|
@ -10,7 +10,6 @@ export default {
|
|||||||
// Information about running environment
|
// Information about running environment
|
||||||
dev: Boolean(env.dev),
|
dev: Boolean(env.dev),
|
||||||
debug: undefined, // = dev
|
debug: undefined, // = dev
|
||||||
test: Boolean(env.ci || env.test),
|
|
||||||
|
|
||||||
// Mode
|
// Mode
|
||||||
mode: 'universal',
|
mode: 'universal',
|
||||||
@ -31,6 +30,7 @@ export default {
|
|||||||
extensions: [],
|
extensions: [],
|
||||||
|
|
||||||
build: {
|
build: {
|
||||||
|
quiet: Boolean(env.ci || env.test),
|
||||||
analyze: false,
|
analyze: false,
|
||||||
profile: process.argv.includes('--profile'),
|
profile: process.argv.includes('--profile'),
|
||||||
extractCSS: false,
|
extractCSS: false,
|
||||||
|
@ -190,7 +190,11 @@ Options.from = function (_options) {
|
|||||||
options.build.optimization.splitChunks.name = true
|
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
|
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 {
|
export default {
|
||||||
hooks(hook) {
|
hooks(hook) {
|
||||||
hook('build:done', () => {
|
hook('build:done', () => {
|
||||||
consola.success('Compiled successfully')
|
process.stdout.write('Compiled successfully')
|
||||||
})
|
})
|
||||||
hook('listen', (server, { port, host }) => {
|
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 {
|
export default {
|
||||||
buildDir: '.nuxt-generate/.build',
|
buildDir: '.nuxt-generate/.build',
|
||||||
generate: {
|
generate: {
|
||||||
@ -8,9 +6,9 @@ export default {
|
|||||||
hooks(hook) {
|
hooks(hook) {
|
||||||
hook('generate:done', (generator, errors) => {
|
hook('generate:done', (generator, errors) => {
|
||||||
if (!errors || errors.length === 0) {
|
if (!errors || errors.length === 0) {
|
||||||
consola.success('Generated successfully')
|
process.stdout.write('Generated successfully')
|
||||||
} else {
|
} else {
|
||||||
consola.error('Generated failed')
|
process.stderr.write('Generated failed')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user