Skip to content

Commit

Permalink
feat(stylus): support import by allowing files in deps
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Jul 24, 2019
1 parent 804a788 commit 3987070
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/stylus/src/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def _stylus_binary(ctx):
output = ctx.actions.declare_file(src.basename[:-5] + ".css")
ctx.actions.run(
outputs = [output],
inputs = [src],
inputs = [src] + ctx.files.deps,
executable = ctx.executable._compiler,
arguments = [
"--out",
Expand All @@ -28,6 +28,9 @@ stylus_binary = rule(
mandatory = True,
allow_single_file = True,
),
"deps": attr.label_list(
allow_files = True,
),
"_compiler": attr.label(
default = Label("@npm//stylus/bin:stylus"),
cfg = "host",
Expand Down
1 change: 1 addition & 0 deletions packages/stylus/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("@npm_bazel_stylus//:index.bzl", "stylus_binary")
stylus_binary(
name = "styles",
src = "file.styl",
deps = ["liba.styl"],
)

load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_test")
Expand Down
2 changes: 2 additions & 0 deletions packages/stylus/test/file.styl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "liba"

body {
font: 14px/1.5 Helvetica, arial, sans-serif;
#logo {
Expand Down
2 changes: 2 additions & 0 deletions packages/stylus/test/liba.styl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.bar
width: 10px;
4 changes: 4 additions & 0 deletions packages/stylus/test/stylus_binary_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ if (content.indexOf('body #logo') < 0) {
console.error('Expected the css file to be transformed');
process.exitCode = 1;
}
if (content.indexOf('width: 10px') < 0) {
console.error('Expected the css file to be transformed');
process.exitCode = 1;
}

0 comments on commit 3987070

Please sign in to comment.