mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-01-16 04:10:20 -06:00
fix: allow relative baseUrl other than ./ (#2168)
This commit is contained in:
committed by
Evan You
parent
4a035e2fc1
commit
d14d4e693c
@@ -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 }`)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user