Skip to content

Commit

Permalink
fix: prepend config.base to vite/env path (#13941)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe authored Jul 24, 2023
1 parent bbd1ffd commit 8e6cee8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/vite/src/node/plugins/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,14 @@ export function webWorkerPlugin(config: ResolvedConfig): Plugin {
const workerType = query['type']! as WorkerType
let injectEnv = ''

const scriptPath = JSON.stringify(
path.posix.join(config.base, ENV_PUBLIC_PATH),
)

if (workerType === 'classic') {
injectEnv = `importScripts('${ENV_PUBLIC_PATH}')\n`
injectEnv = `importScripts(${scriptPath})\n`
} else if (workerType === 'module') {
injectEnv = `import '${ENV_PUBLIC_PATH}'\n`
injectEnv = `import ${scriptPath}\n`
} else if (workerType === 'ignore') {
if (isBuild) {
injectEnv = ''
Expand Down

0 comments on commit 8e6cee8

Please sign in to comment.