File tree Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Expand file tree Collapse file tree 4 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ NODE_ENV=production ./test
153
153
154
154
## How does it work?
155
155
156
- 1 . Builds index of all stylesheet imports per file.
156
+ 1 . Builds index of all stylesheet imports per file (imports of files with ` .css ` or ` .scss ` extension) .
157
157
1 . Uses [ postcss] ( https://github.com/postcss/postcss ) to parse the matching CSS files.
158
158
1 . Iterates through all [ JSX] ( https://facebook.github.io/react/docs/jsx-in-depth.html ) element declarations.
159
159
1 . Parses the ` styleName ` attribute value into anonymous and named CSS module references.
Original file line number Diff line number Diff line change 14
14
"postcss-modules-local-by-default" : " ^1.1.1" ,
15
15
"postcss-modules-parser" : " ^1.1.0" ,
16
16
"postcss-modules-scope" : " ^1.0.2" ,
17
- "postcss-modules-values" : " ^1.2.2"
17
+ "postcss-modules-values" : " ^1.2.2" ,
18
+ "postcss-scss" : " ^0.4.0"
18
19
},
19
20
"description" : " Transforms styleName to className using compile time CSS module resolution." ,
20
21
"devDependencies" : {
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ export default ({
61
61
inherits : babelPluginJsxSyntax ,
62
62
visitor : {
63
63
ImportDeclaration ( path : Object , stats : Object ) : void {
64
- if ( ! path . node . source . value . endsWith ( '.css' ) ) {
64
+ if ( ! path . node . source . value . endsWith ( '.css' ) && ! path . node . source . value . endsWith ( '.scss' ) ) {
65
65
return ;
66
66
}
67
67
Original file line number Diff line number Diff line change @@ -14,15 +14,24 @@ import LocalByDefault from 'postcss-modules-local-by-default';
14
14
import Parser from 'postcss-modules-parser' ;
15
15
import Scope from 'postcss-modules-scope' ;
16
16
import Values from 'postcss-modules-values' ;
17
+ import ScssSyntax from 'postcss-scss' ;
17
18
import type {
18
19
StyleModuleMapType
19
20
} from './types' ;
20
21
21
22
const getTokens = ( runner , cssSourceFilePath : string ) : StyleModuleMapType => {
23
+ const sourceFilePathIsScss = cssSourceFilePath . endsWith ( '.scss' ) ;
24
+
25
+ const options : Object = {
26
+ from : cssSourceFilePath
27
+ } ;
28
+
29
+ if ( sourceFilePathIsScss ) {
30
+ options . syntax = ScssSyntax ;
31
+ }
32
+
22
33
const lazyResult = runner
23
- . process ( readFileSync ( cssSourceFilePath , 'utf-8' ) , {
24
- from : cssSourceFilePath
25
- } ) ;
34
+ . process ( readFileSync ( cssSourceFilePath , 'utf-8' ) , options ) ;
26
35
27
36
lazyResult
28
37
. warnings ( )
You can’t perform that action at this time.
0 commit comments