Skip to content

Config to exclude files from routing #2930

Description

@tony19

Describe the problem

The following directory layout creates an endpoint for post.spec.js and post.md, and the only way to opt out is to make them private modules with an underscore/dot prefix:

src
└── routes
    └── posts
        ├── post.md  👈 converted to endpoint!
        ├── post.spec.js  👈 converted to endpoint!
        └── post.svelte

Some developers might require the exact layout/naming shown, where:

  1. The files are colocated
  2. The files have the same basename

Describe the proposed solution

Add a configuration option that excludes files.

For example, a kit.excludes config could accept an array of String, RegExp, or Function.

  • String - The basename of the file/directory is compared against the string, and it's excluded if matches.
  • RegExp - The basename of the file/directory is tested against the regular expression, and it's excluded if matches.
  • ({ filepath, basename }) => boolean - The file/directory is excluded if the function returns true.

The default would be [^_.] to match the current behavior. This also would enable users to override the current behavior, allowing for underscore/dot-prefixed files to be included in routing.

Alternatives considered

  • Use underscore/dot prefix to make the files private modules - Defeats requirement 1
  • Store the files outside of src/routes - Defeats requirement 2

Importance

nice to have

Additional Information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions