Skip to content

Commit 12d1194

Browse files
authored
fix: replace import.meta.url correctly (#7792)
1 parent 6198911 commit 12d1194

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/vite/src/node/config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { createLogger } from './logger'
3131
import type { DepOptimizationOptions } from './optimizer'
3232
import { createFilter } from '@rollup/pluginutils'
3333
import type { ResolvedBuildOptions } from '.'
34-
import { parse as parseUrl } from 'url'
34+
import { parse as parseUrl, pathToFileURL } from 'url'
3535
import type { JsonOptions } from './plugins/json'
3636
import type { PluginContainer } from './server/pluginContainer'
3737
import { createPluginContainer } from './server/pluginContainer'
@@ -1008,7 +1008,7 @@ async function bundleConfigFile(
10081008
contents: contents
10091009
.replace(
10101010
/\bimport\.meta\.url\b/g,
1011-
JSON.stringify(`file://${args.path}`)
1011+
JSON.stringify(pathToFileURL(args.path).href)
10121012
)
10131013
.replace(
10141014
/\b__dirname\b/g,

0 commit comments

Comments
 (0)