Skip to content

Commit fdd1c8f

Browse files
author
Todd Anglin
authored
Merge pull request #7 from vakrilov/master
Ability to import SCSS files from node modules
2 parents 123046d + 89fe82f commit fdd1c8f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/converter.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ function convert(logger, projectDir, options) {
1010
options = options || {};
1111

1212
var sassFilesPath = path.join(projectDir, 'app/**/*.scss');
13-
var sassImportPath = path.join(projectDir, 'app/');
14-
//console.log("SASS Import Path", sassImportPath);
13+
var sassImportPaths = [
14+
path.join(projectDir, 'app/'),
15+
path.join(projectDir, 'node_modules/')
16+
];
17+
//console.log("SASS Import Path", sassImportPaths);
1518

1619
var sassFiles = glob.sync(sassFilesPath).filter(function(filePath){
1720
var path = filePath;
@@ -26,7 +29,7 @@ function convert(logger, projectDir, options) {
2629
} else {
2730
var i = 0;
2831
var loopSassFilesAsync = function(sassFiles){
29-
parseSass(sassFiles[i], sassImportPath, function(e){
32+
parseSass(sassFiles[i], sassImportPaths, function(e){
3033
if(e !== undefined){
3134
//Error in the LESS parser; Reject promise
3235
reject(Error(sassFiles[i] + ' SASS CSS pre-processing failed. Error: ' + e));
@@ -48,13 +51,13 @@ function convert(logger, projectDir, options) {
4851
});
4952
}
5053

51-
function parseSass(filePath, importPath, callback){
54+
function parseSass(filePath, importPaths, callback){
5255
var sassFileContent = fs.readFileSync(filePath, { encoding: 'utf8'});
5356
var cssFilePath = filePath.replace('.scss', '.css');
5457

5558
sass.render({
5659
data: sassFileContent,
57-
includePaths: [importPath],
60+
includePaths: importPaths,
5861
outFile: cssFilePath,
5962
outputStyle: 'compressed'
6063
}, function (e, output) {

0 commit comments

Comments
 (0)