refactor(bazel): use multi_sass_binary rule (#28669)
`multi_sass_binary` rules is reinstated in rules_sass v1.17.0 and it is a better solution than list comprehension currently used because it handles imports correctly. PR Close #28669
This commit is contained in:
parent
06ec95f2ef
commit
0c7581da89
|
@ -5,16 +5,12 @@ load("@build_bazel_rules_karma//:defs.bzl", "ts_web_test_suite")
|
||||||
load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle", "history_server")
|
load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle", "history_server")
|
||||||
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
|
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
|
||||||
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver", "ts_library")
|
load("@build_bazel_rules_typescript//:defs.bzl", "ts_devserver", "ts_library")
|
||||||
<% if (sass) { %>load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")
|
<% if (sass) { %>load("@io_bazel_rules_sass//:defs.bzl", "multi_sass_binary")
|
||||||
|
|
||||||
[
|
multi_sass_binary(
|
||||||
sass_binary(
|
name = "styles",
|
||||||
name = "style_" + x,
|
srcs = glob(["**/*.scss"]),
|
||||||
src = x,
|
|
||||||
deps = [],
|
|
||||||
)
|
)
|
||||||
for x in glob(["**/*.scss"])
|
|
||||||
]
|
|
||||||
<% } %>
|
<% } %>
|
||||||
ng_module(
|
ng_module(
|
||||||
name = "src",
|
name = "src",
|
||||||
|
@ -30,7 +26,7 @@ ng_module(
|
||||||
assets = glob([
|
assets = glob([
|
||||||
"**/*.css",
|
"**/*.css",
|
||||||
"**/*.html",
|
"**/*.html",
|
||||||
])<% if (sass) { %> + [":style_" + x for x in glob(["**/*.scss"])]<% } %>,
|
])<% if (sass) { %> + [":styles"]<% } %>,
|
||||||
deps = [
|
deps = [
|
||||||
"@angular//packages/core",
|
"@angular//packages/core",
|
||||||
"@angular//packages/platform-browser",<% if (routing) { %>
|
"@angular//packages/platform-browser",<% if (routing) { %>
|
||||||
|
|
|
@ -95,7 +95,7 @@ export default function(options: BazelWorkspaceOptions): Rule {
|
||||||
'ANGULAR_VERSION': existingVersions.Angular || clean(latestVersions.Angular),
|
'ANGULAR_VERSION': existingVersions.Angular || clean(latestVersions.Angular),
|
||||||
'RXJS_VERSION': existingVersions.RxJs || clean(latestVersions.RxJs),
|
'RXJS_VERSION': existingVersions.RxJs || clean(latestVersions.RxJs),
|
||||||
// TODO(kyliau): Consider moving this to latest-versions.ts
|
// TODO(kyliau): Consider moving this to latest-versions.ts
|
||||||
'RULES_SASS_VERSION': '1.15.1',
|
'RULES_SASS_VERSION': '1.17.0',
|
||||||
};
|
};
|
||||||
|
|
||||||
return mergeWith(apply(url('./files'), [
|
return mergeWith(apply(url('./files'), [
|
||||||
|
|
|
@ -100,9 +100,9 @@ describe('Bazel-workspace Schematic', () => {
|
||||||
'load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")');
|
'load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add sass_binary rules in src/BUILD', () => {
|
it('should add multi_sass_binary rule in src/BUILD', () => {
|
||||||
const content = host.readContent('/src/BUILD.bazel');
|
const content = host.readContent('/src/BUILD.bazel');
|
||||||
expect(content).toContain('load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")');
|
expect(content).toContain('load("@io_bazel_rules_sass//:defs.bzl", "multi_sass_binary")');
|
||||||
expect(content).toContain('glob(["**/*.scss"])');
|
expect(content).toContain('glob(["**/*.scss"])');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue