Skip to content

Commit 07dcd6a

Browse files
committed
build: create sass_bundle bazel rule
This defines a bazel rule to bundle sass partials into a single file using the "sass-bundle" npm package. The rule definition is commented so that it can serve as an example for creating other rules in the future. I've also added the missing build file for badge so that its theme can be included in the bundle.
1 parent 959804b commit 07dcd6a

File tree

44 files changed

+389
-13
lines changed

Some content is hidden

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

44 files changed

+389
-13
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
workspace(name = "angular_material_src")
1+
workspace(name = "angular_material")
22

33
# Add nodejs rules
44
git_repository(

src/cdk/a11y/BUILD.bazel

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ load("@angular//:index.bzl", "ng_module")
33
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library")
44
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library", "ts_web_test")
55

6-
sass_library(
7-
name = "a11y_scss_lib",
8-
srcs = glob(["**/_*.scss"]),
9-
)
10-
116

127
ng_module(
138
name = "a11y",
@@ -22,6 +17,17 @@ ng_module(
2217
tsconfig = ":tsconfig-build.json",
2318
)
2419

20+
# TODO(jelbourn): remove this when sass_library acts like a filegroup
21+
filegroup(
22+
name = "a11y_scss_partials",
23+
srcs = glob(["**/_*.scss"]),
24+
)
25+
26+
sass_library(
27+
name = "a11y_scss_lib",
28+
srcs = [":a11y_scss_partials"],
29+
)
30+
2531
ts_library(
2632
name = "a11y_test_sources",
2733
testonly = 1,

src/cdk/overlay/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ ng_module(
1818
tsconfig = ":tsconfig-build.json",
1919
)
2020

21+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
22+
filegroup(
23+
name = "overlay_scss_partials",
24+
srcs = glob(["**/_*.scss"]),
25+
)
26+
2127
ts_library(
2228
name = "overlay_test_sources",
2329
testonly = 1,

src/lib/BUILD.bazel

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
load("//tools:sass_bundle.bzl", "sass_bundle")
2+
3+
4+
sass_bundle(
5+
name = "theming_bundle",
6+
srcs = [
7+
"//src/cdk/a11y:a11y_scss_partials",
8+
"//src/cdk/overlay:overlay_scss_partials",
9+
"//src/lib/autocomplete:autocomplete_scss_partials",
10+
"//src/lib/badge:badge_scss_partials",
11+
"//src/lib/bottom-sheet:bottom_sheet_scss_partials",
12+
"//src/lib/button-toggle:button_toggle_scss_partials",
13+
"//src/lib/button:button_scss_partials",
14+
"//src/lib/card:card_scss_partials",
15+
"//src/lib/checkbox:checkbox_scss_partials",
16+
"//src/lib/chips:chips_scss_partials",
17+
"//src/lib/core:core_scss_partials",
18+
"//src/lib/datepicker:datepicker_scss_partials",
19+
"//src/lib/dialog:dialog_scss_partials",
20+
"//src/lib/divider:divider_scss_partials",
21+
"//src/lib/expansion:expansion_panel_scss_partials",
22+
"//src/lib/form-field:form_field_scss_partials",
23+
"//src/lib/grid-list:grid_list_scss_partials",
24+
"//src/lib/icon:icon_scss_partials",
25+
"//src/lib/input:input_scss_partials",
26+
"//src/lib/list:list_scss_partials",
27+
"//src/lib/menu:menu_scss_partials",
28+
"//src/lib/paginator:paginator_scss_partials",
29+
"//src/lib/progress-bar:progress_bar_scss_partials",
30+
"//src/lib/progress-spinner:progress_spinner_scss_partials",
31+
"//src/lib/radio:radio_scss_partials",
32+
"//src/lib/select:select_scss_partials",
33+
"//src/lib/sidenav:drawer_scss_partials",
34+
"//src/lib/slide-toggle:slide_toggle_scss_partials",
35+
"//src/lib/slider:slider_scss_partials",
36+
"//src/lib/snack-bar:snack_bar_scss_partials",
37+
"//src/lib/sort:sort_header_scss_partials",
38+
"//src/lib/stepper:stepper_scss_partials",
39+
"//src/lib/table:table_scss_partials",
40+
"//src/lib/tabs:tabs_scss_partials",
41+
"//src/lib/toolbar:toolbar_scss_partials",
42+
"//src/lib/tooltip:tooltip_scss_partials",
43+
],
44+
entry_point = '//src/lib/core:theming/_all-theme.scss',
45+
output_name = "_theming.scss",
46+
)

src/lib/autocomplete/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ ng_module(
2121
tsconfig = ":tsconfig-build.json",
2222
)
2323

24+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
25+
filegroup(
26+
name = "autocomplete_scss_partials",
27+
srcs = glob(["**/_*.scss"]),
28+
)
2429

2530
sass_binary(
2631
name = "autocomplete_scss",

src/lib/badge/BUILD.bazel

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package(default_visibility=["//visibility:public"])
2+
load("@angular//:index.bzl", "ng_module")
3+
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library", "sass_binary")
4+
5+
6+
ng_module(
7+
name = "badge",
8+
srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
9+
module_name = "@angular/material/badge",
10+
deps = [
11+
"//src/lib/core",
12+
"//src/cdk/a11y",
13+
"//src/cdk/coercion",
14+
],
15+
tsconfig = ":tsconfig-build.json",
16+
)
17+
18+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
19+
filegroup(
20+
name = "badge_scss_partials",
21+
srcs = glob(["**/_*.scss"]),
22+
)

src/lib/badge/badge.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Directive, Input, ElementRef, Inject, Optional, NgZone, OnDestroy} from '@angular/core';
10-
import {coerceBooleanProperty} from '@angular/cdk/coercion';
11-
import {ThemePalette} from '@angular/material/core';
129
import {AriaDescriber} from '@angular/cdk/a11y';
10+
import {coerceBooleanProperty} from '@angular/cdk/coercion';
1311
import {DOCUMENT} from '@angular/common';
12+
import {Directive, ElementRef, Inject, Input, NgZone, OnDestroy, Optional} from '@angular/core';
13+
import {ThemePalette} from '@angular/material/core';
14+
1415

1516
let nextId = 0;
1617

src/lib/bottom-sheet/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ ng_module(
2222
tsconfig = ":tsconfig-build.json",
2323
)
2424

25+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
26+
filegroup(
27+
name = "bottom_sheet_scss_partials",
28+
srcs = glob(["**/_*.scss"]),
29+
)
2530

2631
sass_binary(
2732
name = "bottom_sheet_container_scss",

src/lib/button-toggle/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ ng_module(
1717
tsconfig = ":tsconfig-build.json",
1818
)
1919

20+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
21+
filegroup(
22+
name = "button_toggle_scss_partials",
23+
srcs = glob(["**/_*.scss"]),
24+
)
2025

2126
sass_binary(
2227
name = "button_toggle_scss",

src/lib/button/BUILD.bazel

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ ng_module(
1616
tsconfig = ":tsconfig-build.json",
1717
)
1818

19+
# TODO(jelbourn): remove this when sass_library acts like a filegroup
20+
filegroup(
21+
name = "button_scss_partials",
22+
srcs = glob(["**/_*.scss"]),
23+
)
1924

2025
# Library of all button scss partials.
2126
sass_library(
2227
name = "button_scss_lib",
23-
srcs = glob(["**/_*.scss"]),
28+
srcs = [":button_scss_partials"],
2429
deps = ["//src/lib/core:core_scss_lib"],
2530
)
2631

src/lib/card/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ ng_module(
1414
tsconfig = ":tsconfig-build.json",
1515
)
1616

17+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
18+
filegroup(
19+
name = "card_scss_partials",
20+
srcs = glob(["**/_*.scss"]),
21+
)
1722

1823
sass_binary(
1924
name = "card_scss",

src/lib/checkbox/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ ng_module(
1717
tsconfig = ":tsconfig-build.json",
1818
)
1919

20+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
21+
filegroup(
22+
name = "checkbox_scss_partials",
23+
srcs = glob(["**/_*.scss"]),
24+
)
2025

2126
sass_binary(
2227
name = "checkbox_scss",

src/lib/chips/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ ng_module(
2020
tsconfig = ":tsconfig-build.json",
2121
)
2222

23+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
24+
filegroup(
25+
name = "chips_scss_partials",
26+
srcs = glob(["**/_*.scss"]),
27+
)
2328

2429
sass_binary(
2530
name = "chips_scss",

src/lib/core/BUILD.bazel

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package(default_visibility=["//visibility:public"])
2+
23
load("@angular//:index.bzl", "ng_module")
34
load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library", "sass_binary")
45

6+
exports_files(["theming/_theming.scss"])
7+
58

69
ng_module(
710
name = "core",
@@ -19,10 +22,16 @@ ng_module(
1922
)
2023

2124

25+
# TODO(jelbourn): remove this when sass_library acts like a filegroup
26+
filegroup(
27+
name = "core_scss_partials",
28+
srcs = glob(["**/_*.scss"]),
29+
)
30+
2231
# Library of all core scss partials.
2332
sass_library(
2433
name = "core_scss_lib",
25-
srcs = glob(["**/_*.scss"]),
34+
srcs = [":core_scss_partials"],
2635
deps = ["//src/cdk/a11y:a11y_scss_lib"],
2736
)
2837

src/lib/datepicker/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ ng_module(
2828
tsconfig = ":tsconfig-build.json",
2929
)
3030

31+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
32+
filegroup(
33+
name = "datepicker_scss_partials",
34+
srcs = glob(["**/_*.scss"]),
35+
)
3136

3237
sass_binary(
3338
name = "datepicker_content_scss",

src/lib/dialog/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ ng_module(
1919
tsconfig = ":tsconfig-build.json",
2020
)
2121

22+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
23+
filegroup(
24+
name = "dialog_scss_partials",
25+
srcs = glob(["**/_*.scss"]),
26+
)
2227

2328
sass_binary(
2429
name = "dialog_scss",

src/lib/divider/BUILD.bazel

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ ng_module(
1616
)
1717

1818

19+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
20+
filegroup(
21+
name = "divider_scss_partials",
22+
srcs = glob(["**/_*.scss"]),
23+
)
24+
1925
sass_library(
2026
name = "divider_scss_lib",
2127
srcs = ["divider.scss"],
2228
deps = ["//src/lib/core:core_scss_lib"],
2329
)
2430

25-
2631
sass_binary(
2732
name = "divider_scss",
2833
src = "divider.scss",

src/lib/expansion/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ ng_module(
2323
tsconfig = ":tsconfig-build.json",
2424
)
2525

26+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
27+
filegroup(
28+
name = "expansion_panel_scss_partials",
29+
srcs = glob(["**/_*.scss"]),
30+
)
2631

2732
sass_binary(
2833
name = "expansion_panel_scss",

src/lib/form-field/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ ng_module(
2323
tsconfig = ":tsconfig-build.json",
2424
)
2525

26+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
27+
filegroup(
28+
name = "form_field_scss_partials",
29+
srcs = glob(["**/_*.scss"]),
30+
)
31+
2632
sass_binary(
2733
name = "form_field_scss",
2834
src = "form-field.scss",

src/lib/grid-list/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ ng_module(
1515
tsconfig = ":tsconfig-build.json",
1616
)
1717

18+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
19+
filegroup(
20+
name = "grid_list_scss_partials",
21+
srcs = glob(["**/_*.scss"]),
22+
)
1823

1924
sass_binary(
2025
name = "grid_list_scss",

src/lib/icon/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ ng_module(
1414
tsconfig = ":tsconfig-build.json",
1515
)
1616

17+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
18+
filegroup(
19+
name = "icon_scss_partials",
20+
srcs = glob(["**/_*.scss"]),
21+
)
1722

1823
sass_binary(
1924
name = "icon_scss",

src/lib/input/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ ng_module(
1717
tsconfig = ":tsconfig-build.json",
1818
)
1919

20+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
21+
filegroup(
22+
name = "input_scss_partials",
23+
srcs = glob(["**/_*.scss"]),
24+
)
2025

2126
sass_binary(
2227
name = "input_scss",

src/lib/list/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ ng_module(
2020
)
2121

2222

23+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
24+
filegroup(
25+
name = "list_scss_partials",
26+
srcs = glob(["**/_*.scss"]),
27+
)
28+
2329
sass_binary(
2430
name = "list_scss",
2531
src = "list.scss",

src/lib/menu/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ ng_module(
2020
tsconfig = ":tsconfig-build.json",
2121
)
2222

23+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
24+
filegroup(
25+
name = "menu_scss_partials",
26+
srcs = glob(["**/_*.scss"]),
27+
)
2328

2429
sass_binary(
2530
name = "menu_scss",

src/lib/paginator/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ ng_module(
1919
)
2020

2121

22+
# TODO(jelbourn): replace this w/ sass_library when it supports acting like a filegroup
23+
filegroup(
24+
name = "paginator_scss_partials",
25+
srcs = glob(["**/_*.scss"]),
26+
)
27+
2228
sass_binary(
2329
name = "paginator_scss",
2430
src = "paginator.scss",

0 commit comments

Comments
 (0)