Skip to content

Commit 8e6cee8

Browse files
authored
fix: prepend config.base to vite/env path (#13941)
1 parent bbd1ffd commit 8e6cee8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/vite/src/node/plugins/worker.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,14 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
255255
const workerType = query['type']! as WorkerType
256256
let injectEnv = ''
257257

258+
const scriptPath = JSON.stringify(
259+
path.posix.join(config.base, ENV_PUBLIC_PATH),
260+
)
261+
258262
if (workerType === 'classic') {
259-
injectEnv = `importScripts('${ENV_PUBLIC_PATH}')\n`
263+
injectEnv = `importScripts(${scriptPath})\n`
260264
} else if (workerType === 'module') {
261-
injectEnv = `import '${ENV_PUBLIC_PATH}'\n`
265+
injectEnv = `import ${scriptPath}\n`
262266
} else if (workerType === 'ignore') {
263267
if (isBuild) {
264268
injectEnv = ''

0 commit comments

Comments
 (0)