diff --git a/lib/index.js b/lib/index.js index 94db96f..0a1aa6f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -36,6 +36,17 @@ }, compile = function(config, basePath, files, filename, done) { + if (isPartial(filename)) { + delete files[filename]; + done(); + return; + } + + if (!isAnySassFile(filename)) { + done(); + return; + } + var file = files[filename], filePath = path.join(basePath, filename), opts = extend({ @@ -57,54 +68,47 @@ opts.outFile = filePath.replace(/\.s[ca]ss/, '.css'); } - if (isAnySassFile(filename) === true) { - // Append the file's base path to the available include paths. - opts.includePaths.push(fileDir); - - // Compile the file using SASS. - sass.render(opts, function (err, result) { - var error = null; - - if (err && err instanceof Error) { - error = new Error([ - '[metalsmith-sass] Error: ', - err.message, ' -> ', - err.file, - ':', - err.line, ':', err.column - ].join('')); - } else if (err) { - error = new Error(err); - } + // Append the file's base path to the available include paths. + opts.includePaths.push(fileDir); + + // Compile the file using SASS. + sass.render(opts, function (err, result) { + var error = null; + + if (err && err instanceof Error) { + error = new Error([ + '[metalsmith-sass] Error: ', + err.message, ' -> ', + err.file, + ':', + err.line, ':', err.column + ].join('')); + } else if (err) { + error = new Error(err); + } - if (error) { - done(error); - return; - } + if (error) { + done(error); + return; + } - // add soure map - if (result.map) { - files[dest+'.map'] = { - contents: result.map, - mode: file.mode - }; - } + // add soure map + if (result.map) { + files[dest+'.map'] = { + contents: result.map, + mode: file.mode + }; + } - // replace contents - file.contents = result.css; + // replace contents + file.contents = result.css; - // rename file extension - files[dest] = file; + // rename file extension + files[dest] = file; - delete files[filename]; - done(); - }); - } else if (isPartial(filename) === true) { delete files[filename]; done(); - } else { - done(); - } + }); }, compileSass = function compileSass(config, files, metalsmith, done) {