clinyong / vscode-css-modules

https://marketplace.visualstudio.com/items?itemName=clinyong.vscode-css-modules
MIT License
143 stars 39 forks source link

Autocomplete for imports #65

Open FINDarkside opened 2 years ago

FINDarkside commented 2 years ago

I'm not sure if this is out of scope for this module, but it would be nice to have autocomplete when importing css modules. At the moment I have code like this

import styles from './Block.module.scss';

But vscode will never offer any suggestions when writing the import. Suggestions work just fine when actually using styles.

iChenLei commented 2 years ago

I think it's out of scope, guys.

mindmind commented 2 years ago

it would be really nice

zardoy commented 1 year ago

Actually, this should have been implemented in TypeScript (and I'm sure it can easily be done), but for now I made it work in my extension: https://github.com/zardoy/typescript-vscode-plugins#file-extension-suggestions

import '@/styles/|' // | - files with .module.css will appear here

It works with any extensions in native way to TypeScript, so it will work with aliases, node_modules and so on...

zardoy commented 1 year ago

Will be available in TypeScript 5.0 and available today with TypeScript nightly extension (typescript@next), you just need to have module augmentation in project like import 'vite/client' (still important for js projects)