Skip to content

Commit d459d8d

Browse files
committed
feat: show a sass import
1 parent 307ffd6 commit d459d8d

File tree

8 files changed

+1436
-612
lines changed

8 files changed

+1436
-612
lines changed

angular-ngc/WORKSPACE.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ nodejs_register_toolchains(
3636
)
3737

3838
load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
39+
load("//tools:sass_deps.bzl", "SASS_DEPS")
3940

4041
npm_translate_lock(
4142
name = "npm",
@@ -47,6 +48,10 @@ npm_translate_lock(
4748
custom_postinstalls = {
4849
"ng2-dragula": "ngcc --source .",
4950
},
51+
public_hoist_packages = {
52+
p: ["packages/lib-a"]
53+
for p in SASS_DEPS
54+
},
5055
npmrc = "//:.npmrc",
5156
pnpm_lock = "//:pnpm-lock.yaml",
5257
verify_node_modules_ignored = "//:.bazelignore",

angular-ngc/defs.bzl

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ load("@npm//:html-insert-assets/package_json.bzl", html_insert_assets_bin = "bin
77
load("@npm//:karma/package_json.bzl", _karma_bin = "bin")
88
load("//tools:ng.bzl", "ng_esbuild", "ng_project")
99
load("//tools:ts.bzl", "ts_project")
10-
load("//tools:sass.bzl", "sass")
1110
load("//tools:karma.bzl", "generate_karma_config", "generate_test_bootstrap", "generate_test_setup")
1211

1312
# Common dependencies of Angular applications
@@ -224,7 +223,7 @@ def _pkg_web(name, entry_point, entry_deps, html_assets, assets, production, vis
224223
visibility = visibility,
225224
)
226225

227-
def ng_pkg(name, deps = [], test_deps = [], visibility = ["//visibility:public"]):
226+
def ng_pkg(name, srcs = [], deps = [], test_deps = [], visibility = ["//visibility:public"]):
228227
"""
229228
Bazel macro for compiling an npm-like Angular package project. Creates '{name}' and 'test' targets.
230229
@@ -239,27 +238,19 @@ def ng_pkg(name, deps = [], test_deps = [], visibility = ["//visibility:public"]
239238
240239
Args:
241240
name: the rule name
241+
srcs: source files, if not set then we use **/*.{css,html,ts}
242242
deps: package dependencies
243243
test_deps: additional dependencies for tests
244244
visibility: visibility of the primary targets ('{name}', 'test')
245245
"""
246246

247247
test_spec_srcs = native.glob(["src/**/*.spec.ts"])
248248

249-
srcs = native.glob(
249+
srcs = srcs or native.glob(
250250
["src/**/*.ts", "src/**/*.css", "src/**/*.html"],
251251
exclude = test_spec_srcs,
252252
)
253253

254-
sass_srcs = native.glob(["src/**/*.scss"])
255-
if len(sass_srcs) > 0:
256-
sass(
257-
name = "_sass",
258-
srcs = sass_srcs,
259-
visibility = ["//visibility:private"],
260-
)
261-
srcs = srcs + [":_sass"]
262-
263254
# An index file to allow direct imports of the directory similar to a package.json "main"
264255
write_file(
265256
name = "_index",

angular-ngc/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"type": "module",
66
"dependencies": {
77
"@angular/animations": "15.0.1",
8+
"@angular/cdk": "15.0.1",
89
"@angular/common": "15.0.1",
910
"@angular/core": "15.0.1",
1011
"@angular/forms": "15.0.1",
12+
"@angular/material": "15.0.1",
1113
"@angular/platform-browser": "15.0.1",
1214
"@angular/platform-browser-dynamic": "15.0.1",
1315
"@angular/router": "15.0.1",

angular-ngc/packages/lib-a/BUILD.bazel

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
load("@npm//:defs.bzl", "npm_link_all_packages")
22
load("//:defs.bzl", "ng_pkg")
3+
load("//tools:sass.bzl", sass_binary = "sass")
4+
load("//tools:sass_deps.bzl", "SASS_DEPS")
35

46
package(default_visibility = ["//visibility:public"])
57

68
npm_link_all_packages(name = "node_modules")
79

10+
sass_binary(
11+
name = "css",
12+
srcs = glob(["src/**/*.scss"]),
13+
deps = [
14+
"//:node_modules/@angular/cdk",
15+
"//:node_modules/@angular/material",
16+
] + [
17+
":node_modules/" + p
18+
for p in SASS_DEPS
19+
],
20+
)
21+
822
ng_pkg(
923
name = "lib-a",
24+
srcs = [":css"] + glob(
25+
[
26+
"src/**/*.ts",
27+
"src/**/*.css",
28+
"src/**/*.html",
29+
],
30+
exclude = ["src/**/*.spec.ts"],
31+
),
1032
deps = [
1133
":node_modules/@ngc-example/common",
1234
"//packages/lib-a/src/lib/strings",

angular-ngc/packages/lib-a/src/lib/lib-a.component.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@use '@angular/material' as mat;
2+
13
$color: red;
24

35
:host {

0 commit comments

Comments
 (0)