-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Description
SvelteKit enforces case sensitivity so that your code works if you develop on Mac / Windows and then deploy to Linux. It also becomes easier to work on a code base where people are using different OS.
I'd like to remove SvelteKit's static file serving and rely on Vite's, but we'd first need to standardize the behaviors so that they're the same.
Suggested solution
Here's SvelteKit's solution:
/**
* Determine if a file is being requested with the correct case,
* to ensure consistent behaviour between dev and prod and across
* operating systems. Note that we can't use realpath here,
* because we don't want to follow symlinks
* @param {string} file
* @param {string} assets
* @returns {boolean}
*/
function has_correct_case(file, assets) {
if (file === assets) return true;
const parent = path.dirname(file);
if (fs.readdirSync(parent).includes(path.basename(file))) {
return has_correct_case(parent, assets);
}
return false;
}
Luke has said he doesn't want to add it as an option in sirv (lukeed/sirv#141), so it would need to be implemented in Vite.
Alternative
No response
Additional context
SvelteKit historically hasn't used the publicDir and base options, but does its own static asset serving. I put together a branch to use Vite's implementation, but some of our tests are failing with it due to this issue, which is a blocker for us.
https://github.com/sveltejs/kit/pull/5601/files#r925101030
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.