Skip to content
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

Cannot serve static assets created via "parcel build src/index.html" #2624

Closed
mateja176 opened this issue Feb 9, 2019 · 5 comments
Closed
Labels
🐛 Bug Stale Inactive issues

Comments

@mateja176
Copy link

mateja176 commented Feb 9, 2019

🐛 bug report

App works perfectly when running locally using parcel src/index.html, however after creating a production bundle by running parcel build src/index.html and attempting to serve the static assets using vscode live serve or serve the app is being served with missing CSS and JavaScript files. The same thing happens when the app is served via github pages. Interestingly enough, http-serve is able to serve the app in its entirety. The repository containing whole source code can be found here

🎛 Configuration (.babelrc, package.json, cli command)

package.json

🤔 Expected Behavior

App is being served including CSS and JavaScript files.

😯 Current Behavior

App is served without CSS and JavaScript assets

Errors when accessing page served by github

src.184de31a.css:1 Failed to load resource: the server responded with a status of 404 ()
src.152c138c.js:1 Failed to load resource: the server responded with a status of 404 ()
src.184de31a.css:1 Failed to load resource: the server responded with a status of 404 ()

💁 Possible Solution

Changing the mime types of CSS and JavaScript assets

💻 Code Sample

The repository containing whole source code can be found here

🌍 Your Environment

Software Version(s)
Parcel 1.11.0
Node 10.7.0
npm/Yarn 6.5.0
Operating System Linux
@lustoykov
Copy link
Contributor

Hello @mytee306, you can set the option --public-url. To make github pages work for instance, you have two options:

parcel build src/index.html --public-url='./'.

It would then serve the assets from https://mytee306.github.io/nns/ as opposed to https://mytee306.github.io.

Alternatively

parcel build src/index.html --public-url='/nns' should work too - same logic.

Someone correct me if I'm wrong, but the reason it doesn't work is that by default parcel expects that the bundle is in the server's top-most / root directory. In github pages case, they are nested in nns/. So if you run serve / http-server in dist/ it should work. If you run them one folder above, it won't, unless you set --public-url

@mateja176
Copy link
Author

mateja176 commented Feb 26, 2019

@lustoykov Works like a charm, thank you so much!

@mihailik
Copy link

Shouldn't parcel change default then? Looks like a bug.

@mateja176
Copy link
Author

mateja176 commented Feb 27, 2019

@mihailik I was wondering the same, would be nice to hear the opinion of a contributor. As far as I can tell --public-url './' does not bring unwanted side effects.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.

@github-actions github-actions bot added the Stale Inactive issues label Jan 17, 2020
@github-actions github-actions bot closed this as completed Feb 2, 2020
jam53 added a commit to jam53/sky-screenshot-stats that referenced this issue May 30, 2022
jam53 added a commit to jam53/sky-screenshot-stats that referenced this issue May 30, 2022
Fixed a bug where the website was served without CSS and JavaScript assets
Issue: parcel-bundler/parcel#2624
jam53 added a commit to jam53/sky-screenshot-stats that referenced this issue Mar 16, 2024
jam53 added a commit to jam53/sky-screenshot-stats that referenced this issue May 5, 2024
Fixed a bug where the website was served without CSS and JavaScript assets
Issue: parcel-bundler/parcel#2624
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Stale Inactive issues
Projects
None yet
Development

No branches or pull requests

4 participants