Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format-specific fontsUrl #392

Open
dave-db opened this issue May 12, 2022 · 1 comment
Open

Format-specific fontsUrl #392

dave-db opened this issue May 12, 2022 · 1 comment

Comments

@dave-db
Copy link

dave-db commented May 12, 2022

It would be great to be able to dynamically change the value of fontsUrl based on the output format. For example, we're generating a dist/fonts.css file that is a sibling to the generated fonts, but also an .scss output on a different filepath. Similar to #126, we're setting a sass variable for the root path:

$icon-font-path: "../../dist/fonts" !default;
// ...
@font-face {
    font-family: ${{ name }}-font;
    src: {{{ fontSrc }}};
}

...and setting fontsUrl: '#{$icon-font-path}' in the fantasticon config.

Trouble is, by doing this, we then get the '#{$icon-font-path}' injected in the css output as well, which obviously doesn't work. If we remove the fontsUrl setting, the css output is fine, but then the scss doesn't have the correct url prefix. It would be great if we could set the fontsUrl conditionally, e.g.

// ...
formatOptions: {
    scss: {
      fontsUrl: '#{$icon-font-path}',
    },
}

On #126, a custom template is suggested as a solution here, but I can't see how we can use a template to intercept the fontSrc values as they're written (we're already using a custom template to set the $icon-font-path). Is there a way of intercepting/breaking down the value of fontSrc to allow us to conditionally set fontsUrl?

@mdo
Copy link

mdo commented Jul 16, 2022

This would fix my problem in #126 fwiw. Would be great to have something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants