Webpack loader creating Flow type definitions from CSS Modules files
npm install css-modules-flow-types-loaderWebpack loader for creating Flow type definitions based on CSS Modules files.
This gives you:
- auto-completing for css files in most editors
- flow type safety showing usage of non existing classes
Given the following css file using CSS Modules:
``css
@value primary: red;
.myClass {
color: primary;
}
`
css-modules-flow-types creates the following .flow file next to it:
`javascript`
// @flow
/ This file is automatically generated by css-modules-flow-types /
declare module.exports: {|
+'myClass': string;
+'primary': string;
|};
The css-modules-flow-types-loader need to be added right after after style-loader:
`sh`
$ npm install --dev css-modules-flow-types-loader
$ yarn install -D css-modules-flow-types-loader
`javascript``
{
test: /\.css$/, // or the file format you are using for your CSS Modules
use: [
'style-loader',
'css-modules-flow-types-loader',
// Other loaders like css-loader after this:
{
...
}
]
}