Skip to content

Make entry path relative #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions scripts/vite/src/paths.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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'),
};
Expand Down