Skip to content

Commit

Permalink
feat: support base option during dev, deprecate build.base (#1556)
Browse files Browse the repository at this point in the history
  • Loading branch information
bompus committed Jan 22, 2021
1 parent 705bfc3 commit ba4bce2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/plugin-vue/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export function resolveTemplateCompilerOptions(
// request
if (filename.startsWith(options.root)) {
assetUrlOptions = {
base: '/' + slash(path.relative(options.root, path.dirname(filename)))
base:
options.devServer.config.base +
slash(path.relative(options.root, path.dirname(filename)))
}
}
} else {
Expand Down
7 changes: 4 additions & 3 deletions scripts/jestPerTestSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ beforeAll(async () => {
if (!isBuildTest) {
process.env.VITE_INLINE = 'inline-serve'
server = await (await createServer(options)).listen()
// use resolved port from server
const url = ((global as any).viteTestUrl = `http://localhost:${server.config.server.port}`)
// use resolved port/base from server
const base = server.config.base === '/' ? '' : server.config.base
const url = ((global as any).viteTestUrl = `http://localhost:${server.config.server.port}${base}`)
await page.goto(url)
} else {
process.env.VITE_INLINE = 'inline-build'
Expand Down Expand Up @@ -100,7 +101,7 @@ function startStaticServer(): Promise<string> {
try {
config = require(configFile)
} catch (e) {}
const base = config?.build?.base || ''
const base = (config?.base || '/') === '/' ? '' : config.base

// @ts-ignore
if (config && config.__test__) {
Expand Down

0 comments on commit ba4bce2

Please sign in to comment.