I place this whole thing in to my /assets directory and bring main.scss into the head using resources.Get and toCSS. Lovely!
But, then I notice that there are references in main.scss to the img directory eg:
.element { background-image: url('./img/bg.png');
I get a 404 on the background image because it has not copied over when the site is generated (because no file references it directly with .Permalink or .RelPermalink).
Now I can’t just move the /img directory to /static because:
It would break the directory structure of the imported library
Who knows how many references to /img are strewn throughout main.scss (a typical library will have dozens of scss files) so I’d have to go through and update every reference.
This just feels really silly. Referencing an image using a relative link from a css/scss file is extremely common - I think Hugo’s asset pipeline should support it.
Note: All of the above is assuming I’m not being a huge dummy and missing an obvious way to fix this with existing functionality
Yes you can – buy I would recommend that you mount the directory (using Hugo’s mounts) into static which should solve your problem. It would also be the recommended approach for font files and similar.
Note the “library” is in bold because if the directory structure doesn’t match then relative links in your CSS files for example won’t resolve.