Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lib/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,16 @@ var compile = {
parseCSS: function(filePath, outputFile, errorFunc) {
compile.doParse(fs.readFileSync(filePath, 'utf-8'), filePath, outputFile, errorFunc);
},
parseSCSSLocally: function(filePath, outputFile, errorFunc) {
parseSCSSLocally: function(filePath, outputFile, includePath, errorFunc) {
var css = require('node-sass').renderSync({
file: filePath,
outputStyle: 'compressed'
outputStyle: 'compressed',
includePath: includePath,
}).css.toString();

compile.doParse(css, filePath, outputFile, errorFunc);
},
parseSCSSGlobally: function(filePath, outputFile, errorFunc) {
parseSCSSGlobally: function(filePath, outputFile, includePath, errorFunc) {
var css,
isWin = process.platform == 'win32',
cmd = 'npm',
Expand Down Expand Up @@ -145,7 +146,7 @@ var compile = {
// create temporary file
var tmp_file = path.join(os.tmpdir(),(new Date()).valueOf().toString());

cmdConvert = path.join(pathToGlobalSCSS, 'bin', 'node-sass') + ' --output-style compressed ' + filePath + ' > '+ tmp_file;
cmdConvert = path.join(pathToGlobalSCSS, 'bin', 'node-sass') + ' --output-style compressed --include-path ' + includePath + ' ' + filePath + ' > ' + tmp_file;
childProcess.execSync(cmdConvert, {
env: envObj
});
Expand Down
12 changes: 10 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ module.exports = {
type: 'string',
"default": './',
order: 15
},
includePath: {
title: 'Include Paths',
description: 'Paths to include when importing files. See node-sass --include-path option.',
type: 'string',
"default": './',
order: 16
}
},
installationDir: '',
Expand Down Expand Up @@ -114,6 +121,7 @@ module.exports = {
compileFile: function(filePath) {
var file = path.parse(filePath);
var outputFile = path.resolve(file.dir, atom.config.get(packageName + '.output'), path.parse(filePath).name + '.js').replace(/\\/g, '/');
var includePath = path.resolve(atom.project.getPaths()[0], atom.config.get(packageName + '.includePath'))

if (file.ext == '.css') {
// Normal CSS file conversion
Expand All @@ -127,7 +135,7 @@ module.exports = {
}, 0);
} else if (atom.config.get(packageName + '.useGlobalSass')) {
// SASS/SCSS file conversion with global node-sass package
compile.parseSCSSGlobally(filePath, outputFile, function(message) {
compile.parseSCSSGlobally(filePath, outputFile, includePath, function(message) {
atom.notifications.addError('Error', {
detail: message,
dismissable: false
Expand All @@ -136,7 +144,7 @@ module.exports = {
} else {
// SASS/SCSS file conversion with locally installed node-sass package
setTimeout(function() {
compile.parseSCSSLocally(filePath, outputFile, function(message) {
compile.parseSCSSLocally(filePath, outputFile, includePath, function(message) {
atom.notifications.addError('Error', {
detail: message,
dismissable: false
Expand Down