refactor: move babel defaults value to Options.defaults

This commit is contained in:
Clark Du 2018-03-09 14:30:50 +08:00
parent 97a6f46507
commit f9d2bce5af
No known key found for this signature in database
GPG Key ID: D0E5986AF78B86D9
2 changed files with 9 additions and 9 deletions

View File

@ -177,14 +177,7 @@ module.exports = class Builder {
} }
getBabelOptions({ isServer }) { getBabelOptions({ isServer }) {
const options = _.defaults( const options = _.clone(this.options.build.babel)
{},
this.options.build.babel,
{
babelrc: false,
cacheDirectory: !!this.options.dev
}
)
if (typeof options.presets === 'function') { if (typeof options.presets === 'function') {
options.presets = options.presets({ isServer }) options.presets = options.presets({ isServer })

View File

@ -119,6 +119,11 @@ Options.from = function (_options) {
options.build.cssSourceMap = options.dev options.build.cssSourceMap = options.dev
} }
// babel cacheDirectory
if (options.build.babel.cacheDirectory === undefined) {
options.build.babel.cacheDirectory = options.dev
}
// Debug errors // Debug errors
if (options.debug === undefined) { if (options.debug === undefined) {
options.debug = options.dev options.debug = options.dev
@ -210,7 +215,9 @@ Options.defaults = {
styleResources: {}, styleResources: {},
vendor: [], vendor: [],
plugins: [], plugins: [],
babel: {}, babel: {
babelrc: false
},
postcss: {}, postcss: {},
templates: [], templates: [],
watch: [], watch: [],