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

sapper export --no-subfolders #1021

Closed
wants to merge 1 commit into from

Conversation

bfanger
Copy link

@bfanger bfanger commented Dec 7, 2019

The problem
I want src/routes/foo.svelte to match /foo in the url.

Current situation
src/routes/foo.svelte exports to foo/index.html
Certain static hosting providers (github-pages in my case) will see the generated foo folder and will redirect to /foo/ (with a trailing slash) before displaying the contents of the index.html.

This PR
This PR add a --no-subfolders option to sapper export

The option wil generate /export/foo.html from src/routes/foo.svelte
Github pages and others will match the /foo url to the foo.html file without redirect.

The feature behaves similar to the subFolders option in nuxt

The patch itself is very small, couple of lines in cli.ts and export.ts
But i've also included tests (based on the regular export test) and added a line to the documentation.

@bfanger bfanger force-pushed the feature/no-subfolders branch 2 times, most recently from 6000fde to e7d5b5c Compare December 7, 2019 12:39
@bfanger bfanger force-pushed the feature/no-subfolders branch from e7d5b5c to 8c4302b Compare May 4, 2020 09:51
@bfanger bfanger force-pushed the feature/no-subfolders branch from 8c4302b to eb7a481 Compare June 28, 2020 11:24
@bfanger
Copy link
Author

bfanger commented Jun 28, 2020

I've rebased the upstream changes (fixed the merge conflict)

@benmccann
Copy link
Member

Thanks @bfanger. I think folks are a bit nervous about adding more configuration options until we figure out how exactly to handle configuration. I created an RFC to try to move that conversation along, so please feel free to take a look in case you have any comments about it

@bfanger bfanger force-pushed the feature/no-subfolders branch 3 times, most recently from b08b5f2 to 607cf14 Compare August 16, 2020 20:41
@bfanger
Copy link
Author

bfanger commented Aug 16, 2020

After the sapper 0.28+ rebase, the CI failed on (14, macOS-latest) which is weird, because thats the platform i develop and test on, looking at the error i looks like the tests would pass if the CI server was little faster.

And although the test itself is fast, the before('build app') and before('export app') steps are slow. The tests/apps/export takes about 3s to 7s on my beefy machine. That's too close the the 10s limit imposed by the this.timeout(10000);

@benmccann
Copy link
Member

The tests seem a bit flaky on Mac. I wouldn't worry about it failing on this PR. We're totally open to improvements to make it more robust though 🙂

@bfanger bfanger force-pushed the feature/no-subfolders branch 3 times, most recently from 79245c1 to 034923b Compare January 10, 2021 14:04
Prevent trailing slash redirect for hosts that prefer `export/foo.htm` instead of `export/foo/index.htm` (github pages)
@bfanger bfanger force-pushed the feature/no-subfolders branch from 034923b to 1466cb9 Compare March 7, 2021 15:40
@benmccann
Copy link
Member

Thanks for putting together this PR! Sapper never had a good method of handling configuration, which made it difficult to know how to integrate this feature. However, that's been addressed in SvelteKit by adding a svelte.config.cjs file and adapters. I'm going to go ahead and close this PR since we won't be adding the feature to Sapper. You might like to check out SvelteKit instead. We'll be reviewing PRs for missing features there

@benmccann benmccann closed this Mar 24, 2021
@bfanger
Copy link
Author

bfanger commented Mar 24, 2021

👍 i'll be switching to SvelteKit. Hope this feature wil be part of it.

bfanger pushed a commit to bfanger/kit that referenced this pull request Oct 18, 2021
Usage:
```json
kit: {
    prerender: {
      subfolders: false,
    },
```
Setting the kit.prerender.subfolders setting to false (default is true) will change the filename generation from "/about/index.html" to "/about.html"

Inspiration for the `subfolders` name came from nuxt:
https://nuxtjs.org/docs/configuration-glossary/configuration-generate/#subfolders

- Fixes sveltejs#1443,
- Related to sveltejs#2276, [sapper/sveltejs#1021](sveltejs/sapper#1021)
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.

2 participants