Skip to content

Commit ba4bce2

Browse files
authored
feat: support base option during dev, deprecate build.base (#1556)
1 parent 705bfc3 commit ba4bce2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/plugin-vue/src/template.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ export function resolveTemplateCompilerOptions(
108108
// request
109109
if (filename.startsWith(options.root)) {
110110
assetUrlOptions = {
111-
base: '/' + slash(path.relative(options.root, path.dirname(filename)))
111+
base:
112+
options.devServer.config.base +
113+
slash(path.relative(options.root, path.dirname(filename)))
112114
}
113115
}
114116
} else {

scripts/jestPerTestSetup.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ beforeAll(async () => {
6666
if (!isBuildTest) {
6767
process.env.VITE_INLINE = 'inline-serve'
6868
server = await (await createServer(options)).listen()
69-
// use resolved port from server
70-
const url = ((global as any).viteTestUrl = `http://localhost:${server.config.server.port}`)
69+
// use resolved port/base from server
70+
const base = server.config.base === '/' ? '' : server.config.base
71+
const url = ((global as any).viteTestUrl = `http://localhost:${server.config.server.port}${base}`)
7172
await page.goto(url)
7273
} else {
7374
process.env.VITE_INLINE = 'inline-build'
@@ -100,7 +101,7 @@ function startStaticServer(): Promise<string> {
100101
try {
101102
config = require(configFile)
102103
} catch (e) {}
103-
const base = config?.build?.base || ''
104+
const base = (config?.base || '/') === '/' ? '' : config.base
104105

105106
// @ts-ignore
106107
if (config && config.__test__) {

0 commit comments

Comments
 (0)