diff --git a/packages/@vue/cli-service/lib/Service.js b/packages/@vue/cli-service/lib/Service.js index 5284b6dfc2..12a758d883 100644 --- a/packages/@vue/cli-service/lib/Service.js +++ b/packages/@vue/cli-service/lib/Service.js @@ -7,6 +7,7 @@ const merge = require('webpack-merge') const Config = require('webpack-chain') const PluginAPI = require('./PluginAPI') const loadEnv = require('./util/loadEnv') +const defaultsDeep = require('lodash.defaultsdeep') const { warn, error } = require('@vue/cli-shared-utils') const { defaults, validate } = require('./options') @@ -24,11 +25,8 @@ module.exports = class Service { // load base .env this.loadEnv() - const userOptions = this.loadProjectOptions(projectOptions) - const defaultOptions = defaults() - this.projectOptions = Object.assign({}, defaultOptions, userOptions, { - vueLoader: Object.assign(defaultOptions.vueLoader, userOptions.vueLoader) - }) + const userOptions = this.loadUserOptions(projectOptions) + this.projectOptions = defaultsDeep(userOptions, defaults()) debug('vue:project-config')(this.projectOptions) @@ -156,7 +154,7 @@ module.exports = class Service { return config } - loadProjectOptions (inlineOptions) { + loadUserOptions (inlineOptions) { // vue.config.js let fileConfig, pkgConfig, resolved, resovledFrom const configPath = ( @@ -210,7 +208,7 @@ module.exports = class Service { } // normlaize some options - ensureSlash(resolved, 'base') + ensureSlash(resolved, 'baseUrl') removeSlash(resolved, 'outputDir') // validate options @@ -227,7 +225,7 @@ module.exports = class Service { function ensureSlash (config, key) { if (typeof config[key] === 'string') { config[key] = config[key] - .replace(/^([^/])/, '/$1') + .replace(/^([^/.])/, '/$1') .replace(/([^/])$/, '$1/') } } diff --git a/packages/@vue/cli-service/package.json b/packages/@vue/cli-service/package.json index b9afc0bbfc..f3a3e02641 100644 --- a/packages/@vue/cli-service/package.json +++ b/packages/@vue/cli-service/package.json @@ -42,6 +42,7 @@ "html-webpack-plugin": "^3.0.0", "javascript-stringify": "^1.6.0", "launch-editor-middleware": "^2.2.1", + "lodash.defaultsdeep": "^4.6.0", "minimist": "^1.2.0", "optimize-css-assets-webpack-plugin": "^3.2.0", "ora": "^2.0.0", diff --git a/yarn.lock b/yarn.lock index 56e2c2e198..54d827b4a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6245,6 +6245,10 @@ lodash.defaultsdeep@4.3.2: lodash.mergewith "^4.0.0" lodash.rest "^4.0.0" +lodash.defaultsdeep@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.0.tgz#bec1024f85b1bd96cbea405b23c14ad6443a6f81" + lodash.endswith@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/lodash.endswith/-/lodash.endswith-4.2.1.tgz#fed59ac1738ed3e236edd7064ec456448b37bc09"