mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
refactor
This commit is contained in:
parent
ba8e8abce3
commit
005d967993
@ -55,29 +55,6 @@ export default class Builder extends Tapable {
|
||||
this.styleLoader = styleLoader.bind(this)
|
||||
this.vueLoader = vueLoaderConfig.bind(this)
|
||||
|
||||
// Babel options
|
||||
this.babelOptions = _.defaults(this.options.build.babel, {
|
||||
presets: [
|
||||
require.resolve('babel-preset-vue-app')
|
||||
],
|
||||
babelrc: false,
|
||||
cacheDirectory: !!this.options.dev
|
||||
})
|
||||
|
||||
// Map postcss plugins into instances on object mode once
|
||||
if (isPureObject(this.options.build.postcss)) {
|
||||
if (isPureObject(this.options.build.postcss.plugins)) {
|
||||
this.options.build.postcss.plugins = Object.keys(this.options.build.postcss.plugins)
|
||||
.map(p => {
|
||||
const plugin = require(p)
|
||||
const opts = this.options.build.postcss.plugins[p]
|
||||
if (opts === false) return // Disabled
|
||||
const instance = plugin(opts)
|
||||
return instance
|
||||
}).filter(e => e)
|
||||
}
|
||||
}
|
||||
|
||||
this._buildStatus = STATUS.INITIAL
|
||||
}
|
||||
|
||||
@ -113,8 +90,32 @@ export default class Builder extends Tapable {
|
||||
// Wait for nuxt ready
|
||||
await this.nuxt.ready()
|
||||
|
||||
// Wait for build plugins
|
||||
await this.nuxt.applyPluginsAsync('build', this)
|
||||
|
||||
// Babel options
|
||||
this.babelOptions = _.defaults(this.options.build.babel, {
|
||||
presets: [
|
||||
require.resolve('babel-preset-vue-app')
|
||||
],
|
||||
babelrc: false,
|
||||
cacheDirectory: !!this.options.dev
|
||||
})
|
||||
|
||||
// Map postcss plugins into instances on object mode once
|
||||
if (isPureObject(this.options.build.postcss)) {
|
||||
if (isPureObject(this.options.build.postcss.plugins)) {
|
||||
this.options.build.postcss.plugins = Object.keys(this.options.build.postcss.plugins)
|
||||
.map(p => {
|
||||
const plugin = require(p)
|
||||
const opts = this.options.build.postcss.plugins[p]
|
||||
if (opts === false) return // Disabled
|
||||
const instance = plugin(opts)
|
||||
return instance
|
||||
}).filter(e => e)
|
||||
}
|
||||
}
|
||||
|
||||
// Check if pages dir exists and warn if not
|
||||
this._nuxtPages = typeof this.options.build.createRoutes !== 'function'
|
||||
if (this._nuxtPages) {
|
||||
|
Loading…
Reference in New Issue
Block a user