Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Add support for custom route file extensions. #632

Merged
merged 1 commit into from May 21, 2019

Conversation

pngwn
Copy link
Member

@pngwn pngwn commented Apr 25, 2019

Adds an --ext option to the sapper cli to allow users to define custom file extensions for route components.

I don't know if this is how you would like to achieve this, the Sapper codebase is pretty alien to me, but this seems to work. It still defaults to the old .svelte and .html extensions when no argument is passed.

I added a new folder test/app/custom-extensions with some tests because I needed a custom config to check that arbitrary file extensions worked. I also added some unit tests (or tried) but they all seem to be broken (and switched off) and I don't know enough about what the manifest is supposed to look like to be confident of fixing them. But there is something resembling a unit test for custom extensions in there too.

I've also tested this locally with a sapper-template and it doesn't seem to break any of the builds, with or without an amusing extension (I don't really know how to test dev/export with the AppRunner thing).

I think this would close #219. Not sure if there are any other issues relating to this.

@pngwn
Copy link
Member Author

pngwn commented May 17, 2019

I have updated the tests to match the new test API, fixed the broken unit tests and added an extra unit tests for server routes. Not sure if it was necessary but I did it anyway.

Copy link
Member

@mrkishi mrkishi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@thgh
Copy link
Contributor

thgh commented May 17, 2019

It might have been easier to create a rollup/webpack plugin that resolves .pug or other extensions to .svelte

@Conduitry
Copy link
Member

A bundler plugin wouldn't help - When Sapper is examining the src/routes directory to create a manifest of routes, this is before the bundler is even running. I don't know about webpack, but I don't think renaming a file as part of a plugin is something that can happen anyway - rollup/rollup#530

@Rich-Harris Rich-Harris merged commit b8d99aa into sveltejs:master May 21, 2019
@Rich-Harris
Copy link
Member

I think we should probably support Svelte markdown files by default, if we can just settle on the right extension. Releasing this will allow us to experiment at least. Thanks @pngwn

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sapper shell --ext command for alternate file types
5 participants