sveltejs / sveltejs/kit

Ability to exclude files from compilation

Open
#10,344 6 comments 12 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-decision vite
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proposed configuration in svelte.config.js and trace how source files under src/routes are selected during pnpm build. Check how files such as +page.server.ts are handled, then define the filter behavior so selected files can be excluded without deleting them; done means the build honors the configured exclusions.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.