Closed SC-JBG closed 3 years ago
Hey @SC-JBG :wave:,
Can you paste your HTML file which references the CSS file?
Hey @samrith-s ,
thanks for getting back to me, please find the HTML file down below. I stripped out everything unnecessary to keep it readable, head and script tags are as generated:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello, world!</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="">
<link rel="stylesheet" href="/main.bb27b9fc.css">
</head>
<body>
<h1>Hello, world!</h1>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin=""></script>
<script src="/js/main.95ec2e8c.js"></script>
</body>
</html>
As you can see, the css-file is missing the "css" folder in its path and therefore leads to a 404.
Thank you for having a look at it and take care, Jules
Hey @SC-JBG,
Thank you for that. I was actually asking for your entry file not the generated file.
That way, I can figure out what's happening!
Also, can you remove the .map
files from the globs? There's a bit of a Gotcha around that. From the README:
You should NOT add any structurizer rules for
.map
files as the plugin automatically resolves and restructures the sourcemap files to reside in the same directory as its parent. This can cause unintended side-effects.
Hi @samrith-s ,
Oh, sorry, my bad.
Here is the original index.html that is my entry point:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello, world!</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous">
</head>
<body>
<h1>Hello, world!</h1>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script>
<script src="js/main.js"></script>
</body>
</html>
And main.js content is just importing my SASS stylesheet:
import "../scss/main.scss";
I have now removed *.map from the globs but without any change in behaviour.
Thank you and best, Jules
Alright, that was kinda help for self-help. I recognized that I loaded my SCSS via JS - hence Parcel is generating a css file from it but still tries to load the SCSS via a javascript-sass-loader through the entry JS file - but as there is no SCSS folder available in my dist directory and I never copy over my SCSS files there is nothing to render. If I manually copy my SCSS sources over to dist, the style is loading as expected with the JS file but that is not the automated behaviour I was expecting. So here is my solution that works for me now:
If I remove the SCSS import from my entry point JS file and instead load the SCSS file directly in a link tag within my entry point HTML file, the SCSS-to-CSS generation is correct, paths are looking good and everything runs as expected.
So my solution is to simply load SCSS in entry HTML like this:
<link href="scss/crowdany.scss" rel="stylesheet">
instead of loading it through my entry point JS file via import:
import "../scss/main.scss";
which is a valid option according to https://parceljs.org/scss.html#usage. If you want to still load your SCSS stylesheets via JS you have to copy over your SCSS directory with all sources to the DIST folder via command or however you like in order to work properly.
I am just starting off with Parcel, I think that is simply my fault here not fully understanding how to work with Parcel and SASS. Hope that helps and probably saves you also some time.
Thank you for helping me out and take care, Jules
Hey @SC-JBG , I am looking into this. Hopefully should have something concrete by tomorrow. :smile:
But before I dive into it, could you show me a the list of plugins you are using? Maybe something is interfering with this plugin (will help debug)/
Hey @samrith-s ,
wow you are fast mate :-)
Here are my dependencies, its pretty vanilla actually except for one plugin that I have loaded but actually don't really use anywhere:
"devDependencies": {
"parcel-bundler": "^1.12.5",
"parcel-plugin-clean-dist": "^0.0.6",
"parcel-plugin-structurize": "^2.4.4",
"sass": "^1.34.0"
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hi there,
I am facing an issue when running "parcel build". Apparently the paths required to correctly reference CSS stylesheets are not set correctly within the html file.
Means, if I run
with the following config added to my package.json
I expect my index.html to be rendered with the following references to .css and .js
instead I am getting the following generated, JS looks fine but CSS is not referenced correctly (missing the css/ folder)
My output from the build command looks like this
Any idea how this happened? Am I doing something wrong here?
Thanks a lot and take care, best, Jules