The error looks pretty straightforward, but the problem is that I know my path is right… I’ve done this on countless other Sage projects with no problems, and I’ve checked things maybe a dozen times now.
font-family: “Open Sans”;
src: url("../fonts/OpenSans-Regular.ttf") format(“truetype”);
In resources/assets/fonts, I have a file called OpenSans-Regular.ttf.
When I try to build, I get an error:
Module build failed: ModuleNotFoundError: Module not found: Error: Can’t resolve ‘./fonts/OpenSans-Regular.ttf’ in ‘/Users/user/Sites/example.com/site/web/app/themes/path/resources/assets/styles’
I notice that in the error, there is only one period before /fonts, whereas in my font-face declaration there is 2 periods to indicate going up one directory. Is there a simple explanation for that?
If I try building with my font-face declarations commented out, it’s successful but there is no fonts directory created in the dist folder. But I read that the fonts directory will only show up there if the fonts are being used in the scss files so that’s probably a dead end.
Why does the error make it seem like it’s not going up one directory like I’m telling it to? Everything seems to be written right and named correctly and other projects aren’t having this problem and I don’t get it and my head is like aaaaaaaaaaaaaaaaaaaaa
Here’s a loom video demonstrating (no sound): https://www.loom.com/share/f8335b7aac284352873e67bc73ff9f26
Update: Just found out I can’t get images either. I just tried to use an SVG from the assets/images folder in a CSS pseudo element and I got the same error, with the same single-period instead of two like I typed out.
Also someone pointed out in the replies that I need to go up two directories so I feel like I need to add this: after building, when the assets are in the dist folder, all css gets combined into dist/styles/main.css and I only need to go up a single directory to reach the dist/images and dist/fonts directories. I did try it with 4 periods (../../fonts) a few times, but it doesn’t work. In all sage projects I’ve worked on, I’ve always used two periods and that works correctly.