rules_sass icon indicating copy to clipboard operation
rules_sass copied to clipboard

Import path for external sass repositories?

Open pcj opened this issue 8 years ago • 4 comments

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 avatar Feb 15 '17 16:02 pcj

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.

pcj avatar Feb 15 '17 16:02 pcj

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

sgammon avatar Jun 21 '19 21:06 sgammon

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

thosakwe avatar Jun 13 '21 03:06 thosakwe

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?

motiejus avatar Jun 14 '21 07:06 motiejus