fix(nitro): use file url for #build alias in windows dev (#469)

This commit is contained in:
Daniel Roe 2021-09-05 21:35:54 +01:00 committed by GitHub
parent 8aaa1b3124
commit 0c50af9fd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import { pathToFileURL } from 'url'
import { dirname, join, normalize, relative, resolve } from 'upath'
import type { InputOptions, OutputOptions } from 'rollup'
import defu from 'defu'
@ -209,7 +210,10 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
'#nitro-renderer': normalize(require.resolve(resolve(nitroContext._internal.runtimeDir, 'app', renderer))),
'#config': normalize(require.resolve(resolve(nitroContext._internal.runtimeDir, 'app/config'))),
'#nitro-vue-renderer': vue2ServerRenderer,
'#build': nitroContext._nuxt.buildDir,
// Only file and data URLs are supported by the default ESM loader on Windows (#427)
'#build': nitroContext._nuxt.dev && process.platform === 'win32'
? pathToFileURL(nitroContext._nuxt.buildDir).href
: nitroContext._nuxt.buildDir,
'~': nitroContext._nuxt.srcDir,
'@/': nitroContext._nuxt.srcDir,
'~~': nitroContext._nuxt.rootDir,