How to prevent font files from duplicating in dist folder? #9189
Replies: 4 comments
-
Update: So I cleared the parcel cache which looks like it was part of the issue, and while the fonts are still duplicating, it looks like it's only duplicating them once in the Another thing to note, naming one of my targets "main" caused this weird issue. It was compiling a main folder in both
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I'm starting to think the error logging from the Parcel compiler isn't always 100% accurate as far as font paths are concerned. I changed the url a few times, even to paths that previously threw errors after cache clearing, and I didn't get errors this time. The interesting thing is my images that also pull from a url locally are fine. So either the icon font is corrupted, or there is something with the image path that works better than the font. Still investigating. |
Beta Was this translation helpful? Give feedback.
-
Ok so here is the solution. I made my Sass variable: Second, I placed the fonts folder inside the src folder. Also prevents url errors/duplication of files. Lastly, yes, the font was corrupt. That's why I was seeing squares on the front-end. I guess because I kept moving them around trying to fix the issue. So I re-downloaded them and now everything works fine. Finally! All this headache to get Parcel to properly pull icon fonts when compared to Grunt, I didn't have to fight with that. Grunt compiled the Sass and knew how to handle the urls. Guess that's one pro over Parcel for sure. |
Beta Was this translation helpful? Give feedback.
-
I'm converting from Webpack/Grunt to Parcel, and my project structure looks like this (simplified for example)):
I've set up several targets so I can ensure that I could compile the sass files into
dist/css
and the JS todist/js
. This works okay, although it creates folders for every sass file in dist, but whatever. The issue is the font path. I kept getting "cannot resolve" errors with my font path../fonts/bootstrap/
. Did lots of googling, found docs that say Parcel defaults to relative paths, not absolute etc. So I updated my font path to~/dist/fonts/bootstrap/
. The good news is, no errors when I compile. Yay! 🎉 The bad news, it compiles/copies font files into each dist/css folder so it ends up looking like this:I don't understand why Parcel needs to compile font files at all and then put copies of all files into each individual
dist/css
folder? Why can't I just reference the fonts that permanently live in thedist
folder? I tried setting publicUrl for each target but that's not working. Here is what's in my package.json (trimmed):Beta Was this translation helpful? Give feedback.
All reactions