bazelbuild / rules_sass

Sass rules for Bazel
Apache License 2.0
51 stars 68 forks source link

Import path for external sass repositories? #8

Open pcj opened 7 years ago

pcj commented 7 years ago

Given an external repository definition like so, I'm struggling to figure out what the correct @import path would be for the external sass_library. For example:

# WORKSPACE
MILLIGRAM_BUILD_FILE = """
load("@io_bazel_rules_sass//sass:sass.bzl",
     "sass_binary",
     "sass_library",
)

sass_library(
    name = "milligram",
    srcs = glob(["_*.sass"]),
    visibility = ["//visibility:public"],
)
"""

new_http_archive(
    name = "com_github_milligram_milligram",
    url = "https://github.com/milligram/milligram/archive/v1.3.0.tar.gz",
    strip_prefix = "milligram-1.3.0/src",
    build_file_content = MILLIGRAM_BUILD_FILE,
)
# example/BUILD
sass_binary(
    name = "style",
    src = "style.sass",
    deps = [
        "@com_github_milligram_milligram//:milligram",
    ],
)
// example/style.sass
@import "com_github_milligram_milligram/milligram";
//      ^ What is the correct import here?
pcj commented 7 years ago

Figured it out: need to prefix with external/, such as:

@import "external/com_github_milligram_milligram/milligram";

Will leave this open and close it with a PR to the README.

sgammon commented 5 years ago

@pcj this worked for us too, but it also broke build sandboxing for us.

thosakwe commented 3 years ago

Just adding that you can see the contents of the external/ dir using bazel info execution_root. I didn't know the exact path to import until I looked there:

cd `bazel info execution_root`
ls external
motiejus commented 3 years ago

Thanks for the pointers. This works for the resulting files, but the map file displays a directory that the clients don't like as much:

"sources":["../../../../../../../external/pure.css/file/pure.css","../../../../../../../external/grids-responsive.css/file/grids-responsive.css","../../../../../../../src/hthing/web/static/styles.scss"]

In my case, ideally this should only be

"sources":["pure.css","grids-responsive.css","styles.scss"]

Any pointers how to generate a "resolved" source map?