Skip to content

Commit 89982df

Browse files
committed
fix: fix baseUrl normalization (close #900)
1 parent 6ae1569 commit 89982df

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

packages/@vue/cli-service/lib/Service.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const merge = require('webpack-merge')
77
const Config = require('webpack-chain')
88
const PluginAPI = require('./PluginAPI')
99
const loadEnv = require('./util/loadEnv')
10+
const defaultsDeep = require('lodash.defaultsdeep')
1011
const { warn, error } = require('@vue/cli-shared-utils')
1112

1213
const { defaults, validate } = require('./options')
@@ -24,11 +25,8 @@ module.exports = class Service {
2425
// load base .env
2526
this.loadEnv()
2627

27-
const userOptions = this.loadProjectOptions(projectOptions)
28-
const defaultOptions = defaults()
29-
this.projectOptions = Object.assign({}, defaultOptions, userOptions, {
30-
vueLoader: Object.assign(defaultOptions.vueLoader, userOptions.vueLoader)
31-
})
28+
const userOptions = this.loadUserOptions(projectOptions)
29+
this.projectOptions = defaultsDeep(userOptions, defaults())
3230

3331
debug('vue:project-config')(this.projectOptions)
3432

@@ -156,7 +154,7 @@ module.exports = class Service {
156154
return config
157155
}
158156

159-
loadProjectOptions (inlineOptions) {
157+
loadUserOptions (inlineOptions) {
160158
// vue.config.js
161159
let fileConfig, pkgConfig, resolved, resovledFrom
162160
const configPath = (
@@ -210,7 +208,7 @@ module.exports = class Service {
210208
}
211209

212210
// normlaize some options
213-
ensureSlash(resolved, 'base')
211+
ensureSlash(resolved, 'baseUrl')
214212
removeSlash(resolved, 'outputDir')
215213

216214
// validate options
@@ -227,7 +225,7 @@ module.exports = class Service {
227225
function ensureSlash (config, key) {
228226
if (typeof config[key] === 'string') {
229227
config[key] = config[key]
230-
.replace(/^([^/])/, '/$1')
228+
.replace(/^([^/.])/, '/$1')
231229
.replace(/([^/])$/, '$1/')
232230
}
233231
}

packages/@vue/cli-service/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"html-webpack-plugin": "^3.0.0",
4343
"javascript-stringify": "^1.6.0",
4444
"launch-editor-middleware": "^2.2.1",
45+
"lodash.defaultsdeep": "^4.6.0",
4546
"minimist": "^1.2.0",
4647
"optimize-css-assets-webpack-plugin": "^3.2.0",
4748
"ora": "^2.0.0",

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6245,6 +6245,10 @@ [email protected]:
62456245
lodash.mergewith "^4.0.0"
62466246
lodash.rest "^4.0.0"
62476247

6248+
lodash.defaultsdeep@^4.6.0:
6249+
version "4.6.0"
6250+
resolved "https://registry.yarnpkg.com/lodash.defaultsdeep/-/lodash.defaultsdeep-4.6.0.tgz#bec1024f85b1bd96cbea405b23c14ad6443a6f81"
6251+
62486252
lodash.endswith@^4.2.1:
62496253
version "4.2.1"
62506254
resolved "https://registry.yarnpkg.com/lodash.endswith/-/lodash.endswith-4.2.1.tgz#fed59ac1738ed3e236edd7064ec456448b37bc09"

0 commit comments

Comments
 (0)