Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sibbng committed Nov 10, 2021
1 parent d055e40 commit dde3b12
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/__tests__/build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ describe('resolvePaths', () => {

const resolved = resolve('packages/noname/index.html')

expect(input).toBe(resolved)
expect(config.build.rollupOptions.input[0]).toBe(resolved)
expect(input).toStrictEqual([resolved])
expect(config.build.rollupOptions.input).toStrictEqual([resolved])
})

test('resolve index.html', async () => {
Expand Down
25 changes: 9 additions & 16 deletions packages/vite/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,21 +336,14 @@ export function resolvePaths(config: ResolvedConfig, options: ResolvedConfig["bu

const resolve = (p: string) => path.resolve(config.root, p)

rollupOptions.input = Array.isArray(rollupOptions?.input)
? rollupOptions.input.map(input => resolve(input))
: typeof rollupOptions?.input === 'string'
? resolve(rollupOptions.input)
: undefined

const input = resolve(
libOptions
? libOptions.entry
: typeof options.ssr === 'string'
? options.ssr
: typeof rollupOptions?.input === 'string'
? rollupOptions.input
: 'index.html'
)
if (Array.isArray(rollupOptions?.input))
rollupOptions.input = rollupOptions.input.map(input => resolve(input))

const input = libOptions
? libOptions.entry
: typeof options.ssr === 'string'
? options.ssr
: rollupOptions?.input || 'index.html'

if (ssr && typeof input === 'string' && input.endsWith('.html')) {
throw new Error(
Expand All @@ -360,7 +353,7 @@ export function resolvePaths(config: ResolvedConfig, options: ResolvedConfig["bu
}

return {
input: resolve(input),
input: typeof input === 'string' ? resolve(input) : input,
outDir: resolve(options.outDir)
}
}
Expand Down

0 comments on commit dde3b12

Please sign in to comment.