Ability to exclude files from compilation
Describe the problem
There are times when we need to exclude files from compilation. Here's some examples:
- An app might not have some routes in the PWA build, like
/admin, but it might have them in the SSR build - Some files can be problematic during compilations, like
+page.server.ts
At the moment, these files have to be manually removed before the build then put back afterwards. It's cumbersome.
Describe the proposed solution
In svelte.config.js, define a function that acts as a filter to source code files so we can ignore some files.
Alternatives considered
Right now, if you want to ignore some files, you have to straight up delete them.
find src/routes -name '+*.server.*' -delete
pnpm build
http-server ./build
git checkout -- 'src/routes/+*.server.*'
Importance
would make my life easier
Additional Information
- Fixes https://github.com/sveltejs/kit/issues/10332
- https://github.com/sveltejs/kit/issues/6031#issuecomment-1593328625
A more general solution would probably be some sort of plugin system where people can influence routes, and that could be done through that.
I would like to bring this up again, and broaden the scope a bit; I want to exclude *.stories.svelte and *.spec.ts from the build artifacts, but there really doesn't seem to be a good way to do this.
This is possible since a while via the typescript option: https://svelte.dev/docs/kit/configuration#typescript
Edit: misread this, sorry for the noise
This is possible since a while via the typescript option: https://svelte.dev/docs/kit/configuration#typescript
Edit: misread this, sorry for the noise
I wish you could be a bit more specific. If I have a routes/dev folder, how do I exclude it? What file do I change and how?
I have the same problem with *.page.ts, To hold Page Object Models for testing. Better for these to be co-located. @Radiergummi
Co-location of files reduces cognitive load.
I am confused on how to actually exclude pattern of files too. @dsfaccini