electron-userland / electron-compilers

DEPRECATED: Compiler implementations for electron-compile
35 stars 55 forks source link

Add support for Sass `includePaths` option #55

Closed saschagehlich closed 7 years ago

saschagehlich commented 7 years ago

This allows you to @import files from specified includePaths in your .sass / .scss files. I also added a test suite (mocha) and a test for this feature.

A little description on what this actually does:

If an includePaths option is specified, the sass compiler calls Sass.importer and passes an importer method that correctly resolves the import requests by iterating over the include paths and resolving the request to the correct file name. It then writes the file content to emscripten's memory using Sass.writeFile and asks the sass compiler to use the specified path for the import.

anaisbetts commented 7 years ago

Tests are all in electron-compile, put them there instead and use npm link to test your changes

saschagehlich commented 7 years ago

While this PR works fine, it seems to break electron-compile's compiler-info.json.gz file, which does not include SassCompiler's compilerOptions anymore, causing the CompileCache to generate an incorrect digest when resolving a file from a packaged application. No idea where this comes from though. Any ideas @paulcbetts ?

anaisbetts commented 7 years ago

@saschagehlich I'll look into it

anaisbetts commented 7 years ago

Imma fix this up tomorrow, sorry it's taking foreverrrrr

anaisbetts commented 7 years ago

Hey @saschagehlich, sorry this took forever. Sass actually already had an option called paths which also keeps track of the seen directories, so I used that value instead. electron-compilers 5.4.0 has this change

saschagehlich commented 7 years ago

@paulcbetts Cool, thanks! Were you able to reproduce the issue I mentioned above?

anaisbetts commented 7 years ago

No, I tested it with an electron-forge demo app and it all worked (though I didn't try setting an explicit paths I don't see why it would be different), both dev and packaged modes

saschagehlich commented 7 years ago

@paulcbetts I just started using electron-compile in a project again and it seems that paths is not a valid option for sass.js :(

alexstrat commented 7 years ago

Exactly the paths option is passed to the sass.js's compile and throw an error because not a valid option.

alexstrat commented 7 years ago

Fixed in https://github.com/electron/electron-compilers/pull/75