activeguild / vite-plugin-sass-dts

This is a plugin that automatically creates a type file when using the CSS module type-safely.
MIT License
116 stars 18 forks source link

Importing an scss file that uses the common namespace results in error #96

Closed iPapatsoris closed 4 months ago

iPapatsoris commented 4 months ago

In the react-sass example, if I add the line @use '../App.module.scss'; on User.module.scss, I receive

Error: There is no module with the namespace "common". ╷ 8 │ background-color: common.$primary; │ ^^^^^^^^^^^^^^^ ╵ src/App.module.scss 8:21 @use src/User/User.module.scss 1:27 root stylesheet

activeguild commented 4 months ago

@iPapatsoris

This is an error because User.module.scss is interpreted and transpiled as follows, which is beyond the scope of this plugin because it is a sass error. I thought it would be a good idea to review the file dependencies.

@use '@/styles' as common;
@use '../App.module.scss';

.name {
  line-height: 1;
}
iPapatsoris commented 4 months ago

Ah yes, you are right. I wasn't aware that it was a native SASS error. Thanks for the help!