Skip to content

Commit

Permalink
fix: fix baseUrl normalization (close #900)
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 3, 2018
1 parent 6ae1569 commit 89982df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/@vue/cli-service/lib/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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)

Expand Down Expand Up @@ -156,7 +154,7 @@ module.exports = class Service {
return config
}

loadProjectOptions (inlineOptions) {
loadUserOptions (inlineOptions) {
// vue.config.js
let fileConfig, pkgConfig, resolved, resovledFrom
const configPath = (
Expand Down Expand Up @@ -210,7 +208,7 @@ module.exports = class Service {
}

// normlaize some options
ensureSlash(resolved, 'base')
ensureSlash(resolved, 'baseUrl')
removeSlash(resolved, 'outputDir')

// validate options
Expand All @@ -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/')
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 89982df

Please sign in to comment.