Reputation: 1958
I'm looking for the fast and simple way to build a simple production single page application with parcel, react and GitHub pages. I was trying to bundle the output from parcel build index.html
with the gh-pages plugin as a raw project but with no success.... The gh-pages project isn't loading as expected. When I do load it instead with use of the base react app cli following this tutorial (https://www.youtube.com/watch?v=nyjarJhVQMM&t=) for ex. it works fine. And after build steps I can see my app is loading on given gh-pages homepage. But I feel like I am missing something with parcel bundle. Can someone point me the right way?
Thank you a lot!
Upvotes: 3
Views: 1374
Reputation: 15955
By default, I believe Parcel references your CSS and JavaScript as root paths, which fail to load when you deploy to GitHub pages which require a relative path.
To build, add --public-url '.'
to your build command:
parcel build index.html --public-url '.'
This will change https://user.github.io/my-script.js to https://user.github.io/project/my-script.js
Upvotes: 3