Closed parro-it closed 9 years ago
Hi, I'm trying to use electron-compile to compile a sass file. I have to import bootstrap-sass, so I pass includePaths option to electron-compile
includePaths
require('electron-compile').initWithOptions({ cacheDir: join(__dirname, '/cache'), compilerOpts: { // Compiler options are a map of extension <=> options for compiler js: { stage: 0}, scss: { includePaths: [ join(__dirname, 'node_modules/bootstrap-sass/assets/stylesheets'), ]}; } });
But it appear that the option is just ignored... Digging in source files, I think I found that the problem is in electron-compilers/src/css/scss.js.
In method compile, you are overriding the includePaths option:
compile(sourceCode, filePath) { let paths = Object.keys(this.seenFilePaths); paths.unshift('.'); let opts = _.extend({}, this.compilerInformation, { data: sourceCode, indentedSyntax: filePath.match(/\.sass$/i), sourceMapRoot: filePath, includePaths: paths, filename: path.basename(filePath) }); let result = scss.renderSync(opts); return result.css.toString('utf8'); }
I solved the problem by do a concat with the given option, saved in constructor:
compile(sourceCode, filePath) { let paths = Object.keys(this.seenFilePaths); paths.unshift('.'); ///////////////////// ///////////////////// ///////////////////// paths = paths.concat(this.compilerInformation.includePaths); ///////////////////// ///////////////////// ///////////////////// let opts = _.extend({}, this.compilerInformation, { data: sourceCode, indentedSyntax: filePath.match(/\.sass$/i), sourceMapRoot: filePath, includePaths: paths, filename: path.basename(filePath) }); let result = scss.renderSync(opts); return result.css.toString('utf8'); }
If you think my solution it's ok, I can prepare a PR
@parro-it Oops, I think you're right! Can you send a PR?
Yes, sure, I'll prepare it soon.
Fixed in #3
Hi, I'm trying to use electron-compile to compile a sass file. I have to import bootstrap-sass, so I pass
includePaths
option to electron-compileBut it appear that the option is just ignored... Digging in source files, I think I found that the problem is in electron-compilers/src/css/scss.js.
In method compile, you are overriding the includePaths option:
I solved the problem by do a concat with the given option, saved in constructor:
If you think my solution it's ok, I can prepare a PR