From 4074189336743831d210d894e2966bdd84586e0a Mon Sep 17 00:00:00 2001 From: Arjan van Wijk Date: Tue, 9 May 2023 13:20:22 +0200 Subject: [PATCH] Make entry path relative As absolute, it would not load on windows. --- scripts/vite/src/paths.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/vite/src/paths.ts b/scripts/vite/src/paths.ts index a07f6b54..5bd44a0d 100644 --- a/scripts/vite/src/paths.ts +++ b/scripts/vite/src/paths.ts @@ -1,5 +1,5 @@ import { fileURLToPath } from 'url'; -import { resolve, dirname } from 'path'; +import { resolve, dirname, relative } from 'path'; import { cwd } from 'process'; function createPaths() { @@ -22,7 +22,13 @@ function createPaths() { proxySetup: resolve(user, 'service-worker.js'), // Paths relative to the source directory - entry: resolve(source, 'main.ts'), + /* + When this is an absolute path, on windows it will be loaded as `file://c:/...`. + Instead it would ideally be loaded as `/c:/...` as a valid "url". + However, if we make it relative like `src/main.ts`, it will work on both systems. + This path is inserted into the index.html, so we need to make it relative. + */ + entry: relative(paths.user, resolve(source, 'main.ts')), serviceWorker: resolve(source, 'service-worker.ts'), };