module-builder
module-builder copied to clipboard
Vue SFC vite.css.preprocessorOptions.scss.additionalData cannot run `nuxt-module-build`
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.
- Is this behavior expected ?
- How can I mimic / replace my module config with a build config so
nuxt-module-buidler
works ?
References:
- https://github.com/nuxt/module-builder/issues/87
- https://github.com/unjs/mkdist
- https://github.com/unjs/unbuild
You should look at the solution described here, which seem to address exactly your problem https://github.com/nuxt/module-builder/issues/90