Skip to content

Commit 6da135f

Browse files
committed
build: re-root style files for bazel cdk package
The CDK contains stylesheet files which are re-rooted at the NPM package root. This needs to be done for the bazel package as well as it would otherwise break a lot of consumers.
1 parent d4ca378 commit 6da135f

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

packages.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,17 @@ CDK_PACKAGES = [
1616
"scrolling",
1717
"stepper",
1818
"table",
19+
"testing",
1920
"text-field",
2021
"tree",
2122
]
2223

24+
CDK_TARGETS_WITH_STYLES = [
25+
"a11y",
26+
"overlay",
27+
"text-field",
28+
]
29+
2330
CDK_TARGETS = ["//src/cdk"] + ["//src/cdk/%s" % p for p in CDK_PACKAGES]
2431

2532
CDK_EXPERIMENTAL_PACKAGES = [

src/cdk/BUILD.bazel

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

3-
load("//:packages.bzl", "CDK_PACKAGES", "CDK_TARGETS", "ROLLUP_GLOBALS")
3+
load("//:packages.bzl", "CDK_PACKAGES", "CDK_TARGETS", "CDK_TARGETS_WITH_STYLES", "ROLLUP_GLOBALS")
44
load("//tools:defaults.bzl", "ng_module", "ng_package")
55

66
# Root "@angular/cdk" entry-point that does not re-export individual entry-points.
@@ -16,6 +16,35 @@ ng_module(
1616
],
1717
)
1818

19+
# List of style files that need to be copied to the root of the CDK package. This is
20+
# necessary in order to keep the Bazel NPM package similar to the previous gulp output.
21+
rerootedStyles = [file for target in CDK_TARGETS_WITH_STYLES for file in [
22+
[
23+
"_%s.scss" % target,
24+
target,
25+
],
26+
[
27+
"%s-prebuilt.css" % target,
28+
target,
29+
],
30+
[
31+
"%s-prebuilt.css.map" % target,
32+
target,
33+
],
34+
]]
35+
36+
# Copy all stylesheets to the CDK root package. We need to copy these files, as
37+
# these stylesheets need to be at the root of the NPM package (e.g. "_a11y.scss")
38+
[genrule(
39+
name = "%s_rerooted" % file,
40+
srcs = ["//src/cdk/%s:%s" % (target, file)],
41+
outs = [file],
42+
cmd = "cp $< $@",
43+
) for [
44+
file,
45+
target,
46+
] in rerootedStyles]
47+
1948
filegroup(
2049
name = "overviews",
2150
srcs = ["//src/cdk/%s:overview" % name for name in CDK_PACKAGES],
@@ -25,11 +54,12 @@ filegroup(
2554
ng_package(
2655
name = "npm_package",
2756
srcs = ["package.json"],
57+
data = ["%s_rerooted" % file for [
58+
file,
59+
_,
60+
] in rerootedStyles],
2861
entry_point = ":public-api.ts",
2962
globals = ROLLUP_GLOBALS,
30-
# TODO(devversion): Use the npm package for publishing. Right now this is disabled because
31-
# we build using AOT for serving & testing, but the `ng_package` rule should not include factory
32-
# files.
33-
tags = ["manual"],
63+
tags = ["release-package"],
3464
deps = CDK_TARGETS,
3565
)

0 commit comments

Comments
 (0)