Skip to content

Commit dd535df

Browse files
devversionjosephperrott
authored andcommitted
build: make sass bazel targets consistent (angular#14186)
* Fixes that the `list.scss` accidentally imports the `divider.scss` (while it just wants an actual mixin) * Fixes that the `cdk/a11y` package does not expose the `a11y-prebuilt.css` as Bazel target * Makes all `BUILD` files consistent in regards to Sass targets. * Ensures that each `sass_binary` or `sass_library` has it's **explicit** dependencies. Currently it's not possible to depend on a single target (depending on transitive build outputs/targets) * Removes the `_partials` filegroups because those can be replaced with a `sass_library` now. Also removes the `theme` sass_library in favor of the `_scss_lib`. Note that this does not change anything for the `theming_bundle` or `core:all_themes` target.
1 parent bfcb610 commit dd535df

File tree

48 files changed

+248
-408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+248
-408
lines changed

packages.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ MATERIAL_PACKAGES = [
7171

7272
MATERIAL_TARGETS = ["//src/lib:material"] + ["//src/lib/%s" % p for p in MATERIAL_PACKAGES]
7373

74+
# List that references the sass libraries for each Material package. This can be used to create
75+
# the theming scss-bundle or to specify dependencies for the all-theme.scss file.
76+
MATERIAL_SCSS_LIBS = [
77+
"//src/lib/%s:%s_scss_lib" % (p, p.replace('-', '_')) for p in MATERIAL_PACKAGES
78+
]
79+
7480
# Each individual package uses a placeholder for the version of Angular to ensure they're
7581
# all in-sync. This map is passed to each ng_package rule to stamp out the appropriate
7682
# version for the placeholders.

src/cdk-experimental/dialog/BUILD.bazel

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ ng_module(
2222
],
2323
)
2424

25-
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
26-
filegroup(
27-
name = "dialog_container_scss_partials",
28-
srcs = glob(["**/_*.scss"]),
29-
)
30-
3125
sass_binary(
3226
name = "dialog_container_scss",
3327
src = "dialog-container.scss",

src/cdk/a11y/BUILD.bazel

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package(default_visibility=["//visibility:public"])
22

3-
load("@io_bazel_rules_sass//:defs.bzl", "sass_library")
3+
load("@io_bazel_rules_sass//:defs.bzl", "sass_library", "sass_binary")
44
load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
55

66
ng_module(
@@ -19,15 +19,15 @@ ng_module(
1919
]
2020
)
2121

22-
# TODO(jelbourn): remove this when sass_library acts like a filegroup
23-
filegroup(
24-
name = "a11y_scss_partials",
22+
sass_library(
23+
name = "a11y_scss_lib",
2524
srcs = glob(["**/_*.scss"]),
2625
)
2726

28-
sass_library(
29-
name = "a11y_scss_lib",
30-
srcs = [":a11y_scss_partials"],
27+
sass_binary(
28+
name = "a11y_prebuilt_scss",
29+
src = "a11y-prebuilt.scss",
30+
deps = [":a11y_scss_lib"]
3131
)
3232

3333
ng_test_library(

src/cdk/overlay/BUILD.bazel

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,9 @@ ng_module(
2121
],
2222
)
2323

24-
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
25-
filegroup(
26-
name = "overlay_scss_partials",
27-
srcs = glob(["**/_*.scss"]),
28-
)
29-
3024
sass_library(
3125
name = "overlay_scss_lib",
32-
srcs = [":overlay_scss_partials"],
26+
srcs = glob(["**/_*.scss"]),
3327
)
3428

3529
sass_binary(

src/cdk/text-field/BUILD.bazel

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,9 @@ ng_module(
1616
],
1717
)
1818

19-
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
20-
filegroup(
21-
name = "text_field_scss_partials",
22-
srcs = glob(["**/_*.scss"]),
23-
)
24-
2519
sass_library(
2620
name = "text_field_scss_lib",
27-
srcs = [":text_field_scss_partials"],
21+
srcs = glob(["**/_*.scss"]),
2822
)
2923

3024
sass_binary(

src/lib/BUILD.bazel

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package(default_visibility=["//visibility:public"])
22

33
load("@angular//:index.bzl", "ng_package")
44
load("//tools:sass_bundle.bzl", "sass_bundle")
5-
load("//:packages.bzl", "MATERIAL_PACKAGES", "MATERIAL_TARGETS", "ROLLUP_GLOBALS",
6-
"VERSION_PLACEHOLDER_REPLACEMENTS")
75
load("//tools:defaults.bzl", "ng_module")
6+
load("//:packages.bzl", "MATERIAL_PACKAGES", "MATERIAL_TARGETS", "MATERIAL_SCSS_LIBS",
7+
"ROLLUP_GLOBALS", "VERSION_PLACEHOLDER_REPLACEMENTS")
88

99
# Root "@angular/material" entry-point.
1010
ng_module(
@@ -16,15 +16,11 @@ ng_module(
1616

1717
sass_bundle(
1818
name = "theming_bundle",
19-
# Use the filegroup rules for these sass partials directly because sass_library doesn't
20-
# act like a filegroup.
2119
srcs = [
22-
"//src/cdk/a11y:a11y_scss_partials",
23-
"//src/cdk/overlay:overlay_scss_partials",
24-
"//src/cdk/text-field:text_field_scss_partials",
25-
] + [
26-
"//src/lib/%s:%s_scss_partials" % (p, p.replace('-', '_')) for p in MATERIAL_PACKAGES
27-
],
20+
"//src/cdk/a11y:a11y_scss_lib",
21+
"//src/cdk/overlay:overlay_scss_lib",
22+
"//src/cdk/text-field:text_field_scss_lib",
23+
] + MATERIAL_SCSS_LIBS,
2824
entry_point = '//src/lib/core:theming/_all-theme.scss',
2925
output_name = "_theming.scss",
3026
)

src/lib/autocomplete/BUILD.bazel

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,19 @@ ng_module(
2626
]
2727
)
2828

29-
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
30-
filegroup(
31-
name = "autocomplete_scss_partials",
29+
sass_library(
30+
name = "autocomplete_scss_lib",
3231
srcs = glob(["**/_*.scss"]),
32+
deps = ["//src/lib/core:core_scss_lib"],
3333
)
3434

3535
sass_binary(
3636
name = "autocomplete_scss",
3737
src = "autocomplete.scss",
38-
deps = ["//src/lib/core:core_scss_lib"],
39-
)
40-
41-
sass_library(
42-
name = "theme",
43-
srcs = glob(["**/*-theme.scss"]),
38+
deps = [
39+
"//src/cdk/a11y:a11y_scss_lib",
40+
"//src/lib/core:core_scss_lib",
41+
],
4442
)
4543

4644
ng_test_library(

src/lib/badge/BUILD.bazel

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ ng_module(
1616
] + glob(["**/*.html"]),
1717
)
1818

19-
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
20-
filegroup(
21-
name = "badge_scss_partials",
22-
srcs = glob(["**/_*.scss"]),
23-
)
24-
2519
sass_library(
26-
name = "theme",
27-
srcs = glob(["**/*-theme.scss"]),
20+
name = "badge_scss_lib",
21+
srcs = glob(["**/_*.scss"]),
22+
deps = [
23+
"//src/cdk/a11y:a11y_scss_lib",
24+
"//src/lib/core:core_scss_lib",
25+
]
2826
)
2927

3028
ng_test_library(

src/lib/bottom-sheet/BUILD.bazel

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,16 @@ ng_module(
2626
],
2727
)
2828

29-
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
30-
filegroup(
31-
name = "bottom_sheet_scss_partials",
29+
sass_library(
30+
name = "bottom_sheet_scss_lib",
3231
srcs = glob(["**/_*.scss"]),
32+
deps = ["//src/lib/core:core_scss_lib"],
3333
)
3434

3535
sass_binary(
3636
name = "bottom_sheet_container_scss",
3737
src = "bottom-sheet-container.scss",
38-
deps = ["//src/lib/core:core_scss_lib"],
39-
)
40-
41-
sass_library(
42-
name = "theme",
43-
srcs = glob(["**/*-theme.scss"]),
38+
deps = ["//src/cdk/a11y:a11y_scss_lib"],
4439
)
4540

4641
ng_test_library(

src/lib/button-toggle/BUILD.bazel

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,19 @@ ng_module(
1818
],
1919
)
2020

21-
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
22-
filegroup(
23-
name = "button_toggle_scss_partials",
21+
sass_library(
22+
name = "button_toggle_scss_lib",
2423
srcs = glob(["**/_*.scss"]),
24+
deps = ["//src/lib/core:core_scss_lib"]
2525
)
2626

2727
sass_binary(
2828
name = "button_toggle_scss",
2929
src = "button-toggle.scss",
30-
deps = ["//src/lib/core:core_scss_lib"],
31-
)
32-
33-
sass_library(
34-
name = "theme",
35-
srcs = glob(["**/*-theme.scss"]),
30+
deps = [
31+
"//src/cdk/a11y:a11y_scss_lib",
32+
"//src/lib/core:core_scss_lib",
33+
],
3634
)
3735

3836
ng_test_library(

src/lib/button/BUILD.bazel

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,20 @@ ng_module(
1818
],
1919
)
2020

21-
# TODO(jelbourn): remove this when sass_library acts like a filegroup
22-
filegroup(
23-
name = "button_scss_partials",
24-
srcs = glob(["**/_*.scss"]),
25-
)
26-
27-
# Library of all button scss partials.
2821
sass_library(
2922
name = "button_scss_lib",
30-
srcs = [":button_scss_partials"],
23+
srcs = glob(["**/_*.scss"]),
3124
deps = ["//src/lib/core:core_scss_lib"],
3225
)
3326

3427
sass_binary(
3528
name = "button_scss",
3629
src = "button.scss",
37-
deps = [":button_scss_lib"],
38-
)
39-
40-
sass_library(
41-
name = "theme",
42-
srcs = glob(["**/*-theme.scss"]),
30+
deps = [
31+
"//src/cdk/a11y:a11y_scss_lib",
32+
"//src/lib/core:core_scss_lib",
33+
":button_scss_lib"
34+
],
4335
)
4436

4537
ng_test_library(

src/lib/card/BUILD.bazel

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,17 @@ ng_module(
1414
],
1515
)
1616

17-
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
18-
filegroup(
19-
name = "card_scss_partials",
17+
sass_library(
18+
name = "card_scss_lib",
2019
srcs = glob(["**/_*.scss"]),
20+
deps = ["//src/lib/core:core_scss_lib"],
2121
)
2222

2323
sass_binary(
2424
name = "card_scss",
2525
src = "card.scss",
26-
deps = ["//src/lib/core:core_scss_lib"],
27-
)
28-
29-
sass_library(
30-
name = "theme",
31-
srcs = glob(["**/*-theme.scss"]),
26+
deps = [
27+
"//src/cdk/a11y:a11y_scss_lib",
28+
"//src/lib/core:core_scss_lib",
29+
],
3230
)

src/lib/checkbox/BUILD.bazel

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@ ng_module(
2020
],
2121
)
2222

23-
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
24-
filegroup(
25-
name = "checkbox_scss_partials",
23+
sass_library(
24+
name = "checkbox_scss_lib",
2625
srcs = glob(["**/_*.scss"]),
26+
deps = [
27+
"//src/cdk/a11y:a11y_scss_lib",
28+
"//src/lib/core:core_scss_lib",
29+
]
2730
)
2831

2932
sass_binary(
3033
name = "checkbox_scss",
3134
src = "checkbox.scss",
32-
deps = ["//src/lib/core:core_scss_lib"],
33-
)
34-
35-
sass_library(
36-
name = "theme",
37-
srcs = glob(["**/*-theme.scss"]),
35+
deps = [
36+
"//src/cdk/a11y:a11y_scss_lib",
37+
"//src/lib/core:core_scss_lib",
38+
],
3839
)
3940

4041
ng_test_library(

src/lib/chips/BUILD.bazel

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,19 @@ ng_module(
2424
],
2525
)
2626

27-
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
28-
filegroup(
29-
name = "chips_scss_partials",
27+
sass_library(
28+
name = "chips_scss_lib",
3029
srcs = glob(["**/_*.scss"]),
30+
deps = ["//src/lib/core:core_scss_lib"],
3131
)
3232

3333
sass_binary(
3434
name = "chips_scss",
3535
src = "chips.scss",
36-
deps = ["//src/lib/core:core_scss_lib"],
37-
)
38-
39-
sass_library(
40-
name = "theme",
41-
srcs = glob(["**/*-theme.scss"]),
36+
deps = [
37+
"//src/cdk/a11y:a11y_scss_lib",
38+
"//src/lib/core:core_scss_lib",
39+
],
4240
)
4341

4442
ng_test_library(

0 commit comments

Comments
 (0)