Skip to content

Commit

Permalink
fix: ensure proper handling of outDir when root differs from defa…
Browse files Browse the repository at this point in the history
…ult and `outDir` is unset by the user
  • Loading branch information
bent10 committed Apr 24, 2024
1 parent 9cb651b commit 3a6fc6a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/vite/src/loader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFile } from 'node:fs/promises'
import { dirname, join } from 'node:path'
import { dirname, join, relative } from 'node:path'
import type { Plugin } from 'vite'
import { Api } from './Api.js'
import { devCache } from './Cache.js'
Expand Down Expand Up @@ -60,6 +60,12 @@ export function headlessRoute(options?: HeadlessRouteOptions): Plugin<Api> {
})

build.rollupOptions.input = input

// handle `outDir` when `root` is not a default value and `outDir` is not set by the user
if (root !== process.cwd() && build.outDir === 'dist') {
build.outDir = relative(root, build.outDir)
build.emptyOutDir = true
}
},
resolveId(url) {
if (input.includes(url)) {
Expand Down

0 comments on commit 3a6fc6a

Please # to comment.