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

fix: Issues with SASS imports and variables #334

Open
konradsienkowski opened this issue Oct 5, 2023 · 0 comments
Open

fix: Issues with SASS imports and variables #334

konradsienkowski opened this issue Oct 5, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@konradsienkowski
Copy link

🐛 The bug

Hey there,

while trying to implement the module in my application, I noticed two issues:

  1. File scanning doesn't include imports while preparing fallbacks. For example, in nuxt.config.ts I'm adding the main stylesheet file:
css: ['~/assets/scss/main.scss'];

Within it, I'm importing two files with an @import rule:

@import 'fonts.scss';
@import 'typography.scss';

With such configuration, the output CSS file is not affected by the module (neither @font-face rules nor font-family: properties). However, if I add these two files explicitly in nuxt.config.ts:

css: ['~/assets/scss/fonts.scss', '~/assets/scss/typography.scss'],

I can see that both font-face rules and font-family properties were updated by the module.

  1. Updating font-family properties doesn't work properly when these are set with variables. I've added a sass partial with variables in nuxt.config.ts, using vite preprocessor options (following Nuxt docs):
vite: {
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `
            @use "~/assets/scss/_variables.scss" as *;
          `,
        },
      },
    },
  },

Then, in typography.scss I'm using variable in font-family property:

h1 {
  font-family: $fontFamily, sans-serif;
}

which results in an output file/browser inspector:

h1 {
    font-family: "Poppins", "$fontFamily fallback", sans-serif;
}

🛠️ To reproduce

https://stackblitz.com/edit/github-x62ihe?file=nuxt.config.ts

🌈 Expected behaviour

It'd be great to have these working with a module or to have a further information on how to deal with imports/module configuration in such cases

ℹ️ Additional context

No response

@konradsienkowski konradsienkowski added the bug Something isn't working label Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants