rafgraph / spa-github-pages

Host single page apps with GitHub Pages
https://spa-github-pages.rafgraph.dev
MIT License
3.83k stars 565 forks source link

npm module #38

Closed JohnnyJumper closed 3 years ago

JohnnyJumper commented 4 years ago

Do you think it would be beneficial to others to have an npm module that does all of this? Something that an end-user will be able to install with yarn or npm and include in the top file a function that handles redirects? I would love to contribute to the creation of such a thing if you are interested to discuss

rafgraph commented 4 years ago

I think this could be complex with edge cases that make it brittle. The scripts need to be added to the index.html and 404.html files, and depending on build setup these files are not always in the top level (e.g. in create react app they are in the public folder). Also importing the redirect into the spa code seems brittle given the number of spa libraries and build pipelines out there — I think it’s best to have a clear separation between the redirect and spa code. That said, if you want to make a detailed proposal for how this would work I’d consider it.