Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flow module not found with .scss file

I have a file using scss with css-modules like so:

import styles from './Login.scss';

The webpack build works fine but i'm getting a flow error: Required Module Not Found

In my .flowconfig I have

[ignore]
.*/node_modules/fbjs/.*
.*/app/main.js
.*/app/dist/.*
.*/release/.*
.*/git/.*

[include]

[libs]

[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable
esproposal.export_star_as=enable
module.name_mapper.extension='css' -> '<PROJECT_ROOT>/flow/CSSModule.js.flow'
module.name_mapper.extension='styl' -> '<PROJECT_ROOT>/flow/CSSModule.js.flow'
module.name_mapper.extension='png' -> '<PROJECT_ROOT>/flow/WebpackAsset.js.flow'
module.name_mapper.extension='jpg' -> '<PROJECT_ROOT>/flow/WebpackAsset.js.flow'
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue

I've also seen https://github.com/facebook/flow/issues/338 but it doesn't really have any solution.

Has anyone found a workaround for this issue?

like image 471
john_ryan Avatar asked Dec 30 '16 18:12

john_ryan


People also ask

Can I use SCSS in CSS file?

scss files, Sass can import plain old . css files. The only rule is that the import must not explicitly include the . css extension, because that's used to indicate a plain CSS @import .

What is an SCSS file?

What is an SCSS file? SCSS is the second syntax of Sass (Syntactically Awesome Stylesheet) that uses brackets instead of indentations. SCSS was designed in such a way that a valid CSS3 file is also a valid SCSS file. SCSS files are stored with the . scss extension.

What is SCSS module?

scss is SCSS file with CSS modules. According to the repo, CSS modules are: CSS files in which all class names and animation names are scoped locally by default.


2 Answers

A better solution for this error is to use the css-modules-flow-types webpack plugin to generate flow types for your CSS modules.

Flow doesn't know about the scss extension, so you need to add the following to your .flowconfig, in the [options] section:

; Extensions
module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.css
module.file_ext=.scss

You should also add *.scss.flow to your .gitignore. These files shouldn't be checked in because they are automatically generated during the webpack build.

like image 79
ndbroadbent Avatar answered Sep 29 '22 19:09

ndbroadbent


added all the file types I wanted flow to recognize in .flowconfig file

[options]    
module.file_ext=.js
module.file_ext=.json
module.file_ext=.jsx
module.file_ext=.css
module.file_ext=.scss
like image 27
qinggangxu Avatar answered Sep 29 '22 19:09

qinggangxu