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 }) {
const options = _.defaults(
{},
this.options.build.babel,
{
babelrc: false,
cacheDirectory: !!this.options.dev
}
)
const options = _.clone(this.options.build.babel)
if (typeof options.presets === 'function') {
options.presets = options.presets({ isServer })

View File

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