question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

css modules composes from '...' not works

See original GitHub issue

Describe the bug

Compose class names from other file is not working. Vite fails to resolve the path Aliases inside “composes from” not work as well

composes: font-blue from 'blue.module.css';

Reproduction

https://github.com/xSorc/test-vite-composes-from

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: Windows 10 10.0.19042
    CPU: (6) x64 Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz
    Memory: 8.22 GB / 15.94 GB
  Binaries:
    Node: 14.15.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.14.9 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.423.0), Chromium (90.0.818.42)
    Internet Explorer: 11.0.19041.1
  npmPackages:
    vite: 2.2.1 => 2.2.1

Used package manager: yarn

Logs

  vite:load 4ms   [fs] /src/index.module.css +16ms
  vite:load 3ms   [fs] /src/index.module.css +2ms
  vite:load 6ms   [fs] /node_modules/.vite/chunk-R67FPDS3.js?v=04e0b802 +3ms
  vite:rewrite 0ms   [no imports] node_modules\.vite\chunk-R67FPDS3.js?v=04e0b802 +22ms
  vite:transform 0ms   /node_modules/.vite/chunk-R67FPDS3.js?v=04e0b802 +22ms
  vite:time 9ms   /node_modules/.vite/chunk-R67FPDS3.js?v=04e0b802 +11ms
  vite:load 1ms   [fs] /src/index.module.css +8ms
[Error: ENOENT: no such file or directory, open 'C:\C:\Projects\test-vite-composes-from\src\blue.module.css'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\C:\\Projects\\test-vite-composes-from\\src\\blue.module.css'
}
  vite:hmr [detected api usage] src\index.module.css +0ms
  vite:transform 65ms  /src/index.module.css +59ms
  vite:time 70ms  /src/index.module.css +58ms
[Error: ENOENT: no such file or directory, open 'C:\C:\Projects\test-vite-composes-from\src\blue.module.css'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\C:\\Projects\\test-vite-composes-from\\src\\blue.module.css'
}
 

Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
davbritocommented, Aug 15, 2022

This is fixed now with postcss-modules v5

3reactions
Niputicommented, Mar 6, 2022

it’s still reproducible

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Modules composes not working - Stack Overflow
I'm trying to setup css modules with postcss + cssnext. It all seems to be working fine, except that the composes keyword is...
Read more >
A deep dive into CSS Module - LogRocket Blog
Composition is a feature in CSS Module that enables us to compose selectors. Consequently, we can compose a class by inheriting styles from ......
Read more >
Webpack with CSS Modules - E.Y. - Medium
Not long ago, I was tripped over a bug: I updated a dependency package by modifying some css rules. However, the new rule...
Read more >
CSS Modules - Best of JS
CSS Modules. A CSS Module is a CSS file in which all class names and animation names are scoped locally by default. All...
Read more >
CSS Modules by Example - JavaScript Stuff
CSS Modules are a means to achieve locally scoped CSS class names.For a simple one-page app they may not be necessary. But if...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found