How to Use Resources in Asset Pipeline

I would like to be able to reference resources + transformations inside SCSS/CSS asset files. Essentially I’d like to fingerprint font assets and other CSS image assets which will have hashed names for proper caching. However, while it appears you can reference assets from /layouts, /content, it doesn’t appear you can do something similar to this:

A production file might look like this /assets/css/app.scss

@font-face {
  font-family: 'font';
  src: url('{{(resources.Get "/assets/font_55.woff2" | fingerprint "md5").RelPermalink}}') format('woff2')
  font-weight: 400;
  font-style: normal;
}

Even if it’s a workaround. I’d the ability to hash/fingerprint files that are in the assetsDir /assets and have those transferred into the output /public directory while being able to reference those appropriate resources via SCSS (for images/fonts/etc).

I’m not looking for mounts. That works fine for moving specific files from assets over as is without having to duplicate content; however, doesn’t transform.

Thanks Bep

Works when pointing the root scss file; however, doesn’t seem to transform resources that are included via SCSS includes (@import “_somefile”)

Noticed there is another thread on this here

Yes, that is a current limitation – but how is that a problem? I can see how you would want/need to configure your SCSS library with Go templates, but I would personally hate to have Go templates sprinkled around in my includes. Keep your configuration (variables assignment) in one place (the main template) and it works.

The workarounds in the thread are sufficient. After thinking about how Go would have to interpret SCSS imports I can see that being complicated. It’s not a huge pain to just reorganize template/parsing in a single file and then concat that back in. Appreciate the quick feedback.

/resolved

It wouldn’t be particulary hard for SCSS, but I’m not totally sure it would be worth it; and it would require a different API (maybe) than what we currently have.