diff --git a/lib/builder/builder.js b/lib/builder/builder.js index d727df9d8e..5bb25d15b3 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -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) {