Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] include_paths usage #16

Open
hmagrini opened this issue Feb 14, 2018 · 0 comments
Open

[Question] include_paths usage #16

hmagrini opened this issue Feb 14, 2018 · 0 comments

Comments

@hmagrini
Copy link

LibSass defines an option include_paths that helps it resolve files correctly when using the @import directive. It's main use is to define paths that can be imported as "globals" regardless of their actual location.

A simple example can be found here: https://github.com/hmagrini/demo_rules_sass_include_paths

In theory sass_binary should be adding transitive sources as --load-path options here but it doesn't seem to be generating those options for SassC correctly, as the following error is thrown when trying to run the Bazel build (npm run bazel):

ERROR: /hmagrini/demo_rules_sass_include_paths/hello_world/BUILD:5:1: SassCompiler hello_world/hello_world.css failed (Exit 1)
Error: file to import not found or unreadable: shared/fonts
       Current dir: /private/var/tmp/_bazel_hmagrini/db2a0758eaf8ccf7d2e7f7314079fcde/bazel-sandbox/1076353526294901005/execroot/__main__/hello_world/
        on line 1 of hello_world/main.scss
>> @import 'shared/fonts';

On that repo, I've set up 2 builds for the same set of files:

  • npm run bazel which uses rules_sass
  • npm run sass which uses node_sass

This should allow you to verify that this type of usage is valid by running the build that uses node_sass with npm run sass (sorry, I wasn't able to get SassC to build to check directly against it).

Adding some logging you can see the current include_paths option outputs:

SASS:

[ 'styles/shared/_colors.scss',
  'styles/shared/_fonts.scss' ]

BAZEL @ 0.0.3

["-I=<source file styles/shared/_colors.scss>", "-I=<source file styles/shared/_fonts.scss>"]

BAZEL @ c7e0810a6c813a3bc2c9dbbc1f5d696f3c9a8f53 (aka: latest commit on master)

["--load-path", "styles/shared/", "--load-path", "styles/shared/"]

BAZEL @ Editing #L45 to options += ["--load-path", src.path]

["--load-path", "styles/shared/_colors.scss", "--load-path", "styles/shared/_fonts.scss"]

I would really appreciate some pointers into what I'm missing (something in the BUILD files maybe?) or if rules_sass is not correctly generating the expected options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant