fix: fix baseUrl normalization (close #900)

This commit is contained in:
Evan You
2018-03-02 21:40:48 -05:00
parent 6ae1569027
commit 89982dff04
3 changed files with 11 additions and 8 deletions

View File

@@ -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/')
}
}

View File

@@ -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",

View File

@@ -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"