This repository was archived by the owner on Apr 4, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathBUILD.bazel
More file actions
106 lines (96 loc) · 2.9 KB
/
Copy pathBUILD.bazel
File metadata and controls
106 lines (96 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package(default_visibility = ["//visibility:public"])
load("@angular//:index.bzl", "ng_module")
load("@build_bazel_rules_typescript//:defs.bzl", "ts_config", "ts_devserver")
ts_config(
name = "tsconfig-test",
src = "tsconfig-test.json",
deps = [":tsconfig.json"],
)
ng_module(
name = "src",
srcs = glob(["*.ts"]),
assets = [
":app.component.html",
],
tsconfig = ":tsconfig.json",
deps = [
"//src/hello-world",
"//src/todos",
"@angular//packages/core",
"@angular//packages/router",
"@npm//@ngrx/store",
],
)
# This devserver is written in Go and is super-fast.
# It doesn't run any bundler or code splitter. Instead, it concatenates
# UMD JavaScript code on-the-fly in-memory.
# This scales really well for massive codebases.
ts_devserver(
name = "devserver",
# serve these files rooted at /
additional_root_paths = [
"npm/node_modules/zone.js/dist",
"npm/node_modules/tslib",
"npm/node_modules/@ngrx/store/bundles",
],
# Start from the development version of the main
entry_module = "angular_bazel_example/src/main.dev",
scripts = [
":require.config.js",
],
# This is the URL we'll point our <script> tag at
serving_path = "/bundle.min.js",
# Serve these files in addition to the JavaScript bundle
static_files = [
"@npm//node_modules/zone.js:dist/zone.min.js",
"@npm//node_modules/tslib:tslib.js",
"@npm//node_modules/@ngrx/store:bundles/store.umd.min.js",
"index.html",
],
# Tell Bazel to build the sources first
deps = ["//src"],
)
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "rollup_bundle")
rollup_bundle(
name = "bundle",
# These Angular routes may be lazy-loaded at runtime.
# So we tell Rollup that it can put them in separate JS chunks
# (code-splitting) for faster application startup.
# In the future, we could automatically gather these from statically
# analyzing the Angular sources.
additional_entry_points = [
"src/hello-world/hello-world.module.ngfactory",
"src/todos/todos.module.ngfactory",
],
entry_point = "src/main",
deps = [
"//src",
"@npm//@ngrx/store",
],
)
# Copy zone.min.js to this package.
# Needed because the prodserver only loads static files that appear under this
# package.
genrule(
name = "copy_zonejs",
srcs = ["@npm//node_modules/zone.js:dist/zone.min.js"],
outs = ["zone.min.js"],
cmd = "cp $< $@",
)
# See comment for zonejs above
genrule(
name = "copy_systemjs",
srcs = ["@npm//node_modules/systemjs:dist/system.js"],
outs = ["system.js"],
cmd = "cp $< $@",
)
load("@build_bazel_rules_nodejs//:defs.bzl", "history_server")
history_server(
name = "prodserver",
data = [
"index.html",
":bundle",
":copy_systemjs",
":copy_zonejs",
],
)