Skip to content

Commit

Permalink
feat!: relative base (#7644)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed May 18, 2022
1 parent d02b8ac commit 029288a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions playground/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ export function listAssets(base = ''): string[] {
return fs.readdirSync(assetsDir)
}

export function findAssetFile(match: string | RegExp, base = ''): string {
const assetsDir = path.join(testDir, 'dist', base, 'assets')
export function findAssetFile(
match: string | RegExp,
base = '',
assets = 'assets'
): string {
const assetsDir = path.join(testDir, 'dist', base, assets)
const files = fs.readdirSync(assetsDir)
const file = files.find((file) => {
return file.match(match)
Expand Down
8 changes: 6 additions & 2 deletions playground/vitestSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export const serverLogs: string[] = []
export const browserLogs: string[] = []
export const browserErrors: Error[] = []

export let resolvedConfig: ResolvedConfig = undefined!

export let page: Page = undefined!
export let browser: Browser = undefined!
export let viteTestUrl: string = ''
Expand Down Expand Up @@ -199,7 +201,6 @@ export async function startDefaultServe() {
} else {
process.env.VITE_INLINE = 'inline-build'
// determine build watch
let resolvedConfig: ResolvedConfig
const resolvedPlugin: () => PluginOption = () => ({
name: 'vite-plugin-watcher',
configResolved(config) {
Expand Down Expand Up @@ -229,7 +230,10 @@ function startStaticServer(config?: InlineConfig): Promise<string> {
}

// fallback internal base to ''
const base = (config?.base ?? '/') === '/' ? '' : config?.base ?? ''
let base = config?.base
if (!base || base === '/' || base === './') {
base = ''
}

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

0 comments on commit 029288a

Please sign in to comment.