Skip to content

Commit 0d9b1da

Browse files
committed
Add node-sass processor
1 parent f635b35 commit 0d9b1da

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"babel-plugin-syntax-jsx": "^6.18.0",
1111
"babel-types": "^6.26.0",
1212
"generic-names": "^1.0.3",
13+
"node-sass": "^4.9.0",
1314
"postcss": "^6.0.22",
1415
"postcss-modules": "^1.1.0",
1516
"postcss-modules-extract-imports": "^1.1.0",

src/requireCssModule.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import {
88
readFileSync
99
} from 'fs';
10+
import sass from 'node-sass';
1011
import postcss from 'postcss';
1112
import genericNames from 'generic-names';
1213
import ExtractImports from 'postcss-modules-extract-imports';
@@ -70,12 +71,19 @@ const getTokens = (runner, cssSourceFilePath: string, filetypeOptions: ?Filetype
7071
from: cssSourceFilePath
7172
};
7273

74+
let fileContents = readFileSync(cssSourceFilePath, 'utf-8');
75+
7376
if (filetypeOptions) {
74-
options.syntax = getSyntax(filetypeOptions);
77+
if (filetypeOptions.syntax === 'node-sass') {
78+
fileContents = sass.renderSync({file: cssSourceFilePath});
79+
fileContents = fileContents.css.toString();
80+
} else {
81+
options.syntax = getSyntax(filetypeOptions);
82+
}
7583
}
7684

7785
const lazyResult = runner
78-
.process(readFileSync(cssSourceFilePath, 'utf-8'), options);
86+
.process(fileContents, options);
7987

8088
lazyResult
8189
.warnings()

0 commit comments

Comments
 (0)