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

Vue SFC vite.css.preprocessorOptions.scss.additionalData cannot run nuxt-module-build #203

Open
homersimpsons opened this issue Dec 4, 2023 · 1 comment

Comments

@homersimpsons
Copy link

I'm writing a Nuxt Module, in this module I want to use <style> directly in my vue Single File Component.

I have some mixins, functions and variables defined in SCSS and I want to inject them in every <style> so I used the vite.css.preprocessorOptions.scss.additionalData:

extendViteConfig((config) => {
  config.css = defu(config.css || {}, { preprocessorOptions: { scss: { additionalData: '' } } });
  config.css.preprocessorOptions.scss.additionalData += '\n@import "src/assets/imports.scss";\n'
});

This works fine when I use nuxi dev playground, but it fails to compile with nuxt-module-build: SASS cannot find the declared variables / functions.

It looks like this is "expected" as nuxt-module-buidler does not instantiate the module, but I cannot seem to find any reference on how to register my additionalData.

I saw it was possible to write a build.config.ts with a defineBuildConfig but I was not able to find the correct options to use.

  1. Is this behavior expected ?
  2. How can I mimic / replace my module config with a build config so nuxt-module-buidler works ?

References:

@ennioVisco
Copy link

You should look at the solution described here, which seem to address exactly your problem #90

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