fix: allow relative baseUrl other than ./ (#2168)

This commit is contained in:
Barthélémy Ledoux
2018-08-13 11:14:18 -05:00
committed by Evan You
parent 4a035e2fc1
commit d14d4e693c
2 changed files with 21 additions and 1 deletions

View File

@@ -94,6 +94,26 @@ test('handle option baseUrl and outputDir correctly', () => {
expect(service.projectOptions.outputDir).toBe('/public')
})
test('normalize baseUrl when relative', () => {
mockPkg({
vue: {
baseUrl: './foo/bar'
}
})
const service = createMockService()
expect(service.projectOptions.baseUrl).toBe('foo/bar/')
})
test('keep baseUrl when empty', () => {
mockPkg({
vue: {
baseUrl: ''
}
})
const service = createMockService()
expect(service.projectOptions.baseUrl).toBe('')
})
test('load project options from vue.config.js', () => {
process.env.VUE_CLI_SERVICE_CONFIG_PATH = `/vue.config.js`
fs.writeFileSync('/vue.config.js', `module.exports = { lintOnSave: false }`)

View File

@@ -298,10 +298,10 @@ module.exports = class Service {
}
// normalize some options
ensureSlash(resolved, 'baseUrl')
if (typeof resolved.baseUrl === 'string') {
resolved.baseUrl = resolved.baseUrl.replace(/^\.\//, '')
}
ensureSlash(resolved, 'baseUrl')
removeSlash(resolved, 'outputDir')
// deprecation warning