Skip to content

Commit 3987070

Browse files
committed
feat(stylus): support import by allowing files in deps
1 parent 804a788 commit 3987070

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

packages/stylus/src/index.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def _stylus_binary(ctx):
99
output = ctx.actions.declare_file(src.basename[:-5] + ".css")
1010
ctx.actions.run(
1111
outputs = [output],
12-
inputs = [src],
12+
inputs = [src] + ctx.files.deps,
1313
executable = ctx.executable._compiler,
1414
arguments = [
1515
"--out",
@@ -28,6 +28,9 @@ stylus_binary = rule(
2828
mandatory = True,
2929
allow_single_file = True,
3030
),
31+
"deps": attr.label_list(
32+
allow_files = True,
33+
),
3134
"_compiler": attr.label(
3235
default = Label("@npm//stylus/bin:stylus"),
3336
cfg = "host",

packages/stylus/test/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ load("@npm_bazel_stylus//:index.bzl", "stylus_binary")
33
stylus_binary(
44
name = "styles",
55
src = "file.styl",
6+
deps = ["liba.styl"],
67
)
78

89
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_test")

packages/stylus/test/file.styl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "liba"
2+
13
body {
24
font: 14px/1.5 Helvetica, arial, sans-serif;
35
#logo {

packages/stylus/test/liba.styl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.bar
2+
width: 10px;

packages/stylus/test/stylus_binary_spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ if (content.indexOf('body #logo') < 0) {
55
console.error('Expected the css file to be transformed');
66
process.exitCode = 1;
77
}
8+
if (content.indexOf('width: 10px') < 0) {
9+
console.error('Expected the css file to be transformed');
10+
process.exitCode = 1;
11+
}

0 commit comments

Comments
 (0)