-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(adapter-netlify): _redirects file gets overwritten instead of changed #1585
Comments
This was easier to fix than expected. The fix should allow users to have their own `_redirects` file in the project root. If this file exists, it gets copied to `build/` before this adapter appends the catchall rule to it. This behaviour is [already documented](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#using-netlify-redirect-rules), but [currently broken](sveltejs#1585). How can I write an automated test for this adapter? I did the following to test this manually: 1. Use `yarn link "@sveltejs/kit"` and `yarn link "@sveltejs/adapter-netlify"` in my application repository to point the two node modules to my modified versions. 2. Run `svelte-kit build` with a `_redirects` file in the project root. 3. Check if content of `build/_redirects` is expected. 4. Run `svelte-kit build` *without* a `_redirects` file in the project root. 5. Check if content of `build/_redirects` is expected. Any guidance or help how to match the desired code quality to get this PR merged is appreciated. close sveltejs#1585
This was easier to fix than expected. The fix should allow users to have their own `_redirects` file in the project root. If this file exists, it gets copied to `build/` before `adapter-netlify` appends the catchall rule to it. This behaviour is [already documented](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#using-netlify-redirect-rules), but [currently broken](sveltejs#1585). How can I write an automated test for this adapter? I did the following to test this manually: 1. Use `yarn link "@sveltejs/kit"` and `yarn link "@sveltejs/adapter-netlify"` in my application repository to point the two node modules to my modified versions. 2. Run `svelte-kit build` with a `_redirects` file in the project root. 3. Check if content of `build/_redirects` is expected. 4. Run `svelte-kit build` *without* a `_redirects` file in the project root. 5. Check if content of `build/_redirects` is expected. Any guidance or help how to match the desired code quality to get this PR merged is appreciated. close sveltejs#1585
This was easier to fix than expected. The fix should allow users to have their own `_redirects` file in the project root. If this file exists, it gets copied to `build/` before `adapter-netlify` appends the catchall rule to it. This behaviour is [already documented](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#using-netlify-redirect-rules), but [currently broken](sveltejs#1585). How can I write an automated test for this adapter? I did the following to test this manually: 1. Use `yarn link "@sveltejs/kit"` and `yarn link "@sveltejs/adapter-netlify"` in my application repository to point the two node modules to my modified versions. 2. Run `svelte-kit build` with a `_redirects` file in the project root. 3. Check if content of `build/_redirects` is expected. 4. Run `svelte-kit build` *without* a `_redirects` file in the project root. 5. Check if content of `build/_redirects` is expected. Any guidance or help how to match the desired code quality to get this PR merged is appreciated. close sveltejs#1585
This was easier to fix than expected. The fix should allow users to have their own `_redirects` file in the project root. If this file exists, it gets copied to `build/` before `adapter-netlify` appends the catchall rule to it. This behaviour is [already documented](https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#using-netlify-redirect-rules), but [currently broken](sveltejs#1585). How can I write an automated test for this adapter? I did the following to test this manually: 1. Use `yarn link "@sveltejs/kit"` and `yarn link "@sveltejs/adapter-netlify"` in my application repository to point the two node modules to my modified versions. 2. Run `svelte-kit build` with a `_redirects` file in the project root. 3. Check if content of `build/_redirects` is expected. 4. Run `svelte-kit build` *without* a `_redirects` file in the project root. 5. Check if content of `build/_redirects` is expected. Any guidance or help how to match the desired code quality to get this PR merged is appreciated. close sveltejs#1585
I believe there is a small misunderstanding. :) The |
@kvn-shn you're right! Should the documentation be updated to avoid further confusion? Or is it just me and we can assume that people understand that they have to put netlify configuration files into |
I'm going to close this non-issue. Feel free to ask me if I should send a PR to update docs. |
Describe the bug
The documentation clearly says:
See: https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#using-netlify-redirect-rules
This is not quite true. When I put my own
_redirects
into either the root directory orbuild/
folder, the file gets overwritten.To Reproduce
build/_redirects
and add some content:svelte-kit build
build/
is:You can clone my repository and checkout my commit: roschaefer/tanzimpulse@984ba91
Expected behavior
Expected content of
build/_redirects
should be:Information about your SvelteKit Installation:
Diagnostics
npx envinfo --system --npmPackages svelte,@sveltejs/kit,vite --binaries --browsers
Your browser
Irrelevant
Your adapter (e.g. Node, static, Vercel, Begin, etc...)
It's
adapter-netlify
Severity
A bit unfortunate but not a blocking issue. For my use case, this would allow to prerender sites (+performance) while catering noscript-browsers(+accessiblity).
Additional context
I asked at Discord: https://discord.com/channels/457912077277855764/819723698415599626/848204698808352788
Suggestions to Fix
I'm quite sure it's because the entire
build/
folder gets deleted here:kit/packages/adapter-netlify/index.js
Line 15 in 028abd9
appendFileSync
would never find an existing file:kit/packages/adapter-netlify/index.js
Line 42 in 028abd9
Furthermore, I would suggest that users can put a
_redirects
file into the project root folder instead of thebuild/
folder. This would allow users to.gitignore
thebuild/
folder.The text was updated successfully, but these errors were encountered: