Skip to content

Commit

Permalink
fix: allow relative baseUrl other than ./ (#2168)
Browse files Browse the repository at this point in the history
  • Loading branch information
elevatebart authored and yyx990803 committed Aug 13, 2018
1 parent 4a035e2 commit d14d4e6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions packages/@vue/cli-service/__tests__/Service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }`)
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d14d4e6

Please sign in to comment.