koluch / esbuild-plugin-sass

Plugin for esbuild to support SASS styles
45 stars 15 forks source link

error: [sass] Can't find stylesheet to import #13

Closed rodoabad closed 3 years ago

rodoabad commented 3 years ago

I'm having some trouble with files that use @import. Unsure how to proceed on this one.

│ @import '~@foo/branding/styles/variables';
│         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| src/card/card.module.scss 1:9  root stylesheet
│ import styles from './card.module.scss';
│                    ~~~~~~~~~~~~~~~~~~~~
│ node_modules/esbuild-plugin-sass/index.js:92:14: note: This error came from the "onResolve" callback registered here
│         build.onResolve({ filter: /.\.(scss|sass)$/, namespace: "file" }, async (args) => {
╵               ~~~~~~~~~
koluch commented 3 years ago

Hi @rodoabad,

Are you trying to import stylesheet from node_modules/@foo/branding/..., using webpack feature to resolve ~ to node_modules? esbuild doesn't support this feature.

You can import stylesheet you need, specifying relative path explicitly, like this:

@import './node_modules/@foo/branding/styles/variables'
rodoabad commented 3 years ago

Thanks. Looks like I have to change all references to that pattern.