etchteam / storybook-addon-css-variables-theme

Change the CSS variable based design tokens in your storybook on the fly
MIT License
28 stars 12 forks source link

I'm getting "Cannot find module" error #48

Open RezDev94 opened 1 year ago

RezDev94 commented 1 year ago

Hi,

I get this error Cannot find module '!!style-loader?injectType=lazyStyleTag!css-loader!sass-loader!../../scss-variables/light.scss' or its corresponding type declarations.

boligolov commented 10 months ago

Have the same issue

Internal server error: Failed to resolve import "!!style-loader?injectType=lazyStyleTag!css-loader!sass-loader!../src/assets/scss/light.scss" from ".storybook/preview.ts". Does the file exist?

But file exists.

Configuration: vue: 3.3.11, vite: 5.0.10 css-loader: 6.8.1 sass: 1.69.5 sass-loader: 13.3.2 storybook: 7.6.6 style-loader: 3.3.3

marlyse-comte commented 1 month ago

I had the same issue in Storybook 8.3 After doing the following, the issue was resoved:

  1. create styles.d.ts in path/to/src (for me /src/ is a sibling to .storybook
  2. in that file add the following: declare module "*.scss" { const content: Record<string, string>; } NOTE: after doing this, I also had to declare module .mdx

Now, add the following under compilerOptions to your tsconfig.ts file which sits in the .storybook directory: "types": ["../src/styles.d.ts"]

Final note: Storybook 8 no longer needs sass-loader, style-loader, css-loader etc. (I'm using Angular, so your milleage might vary, but I can now import into preview.ts without any issues something like this: import someTheme from '../src/path/to/file/my-styles.scss;