Repository navigation
Expand file tree
/
Copy pathBUILD.bazel
More file actions
106 lines (99 loc) · 3.3 KB
/
Copy pathBUILD.bazel
File metadata and controls
106 lines (99 loc) · 3.3 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")
load("@build_bazel_rules_nodejs//:defs.bzl", "history_server", "rollup_bundle", "web_package")
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/material",
"//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/@angular/material/prebuilt-themes",
"npm/node_modules/@ngrx/store/bundles",
],
# Start from the development version of the main
entry_module = "angular_bazel_example/src/main.dev",
index_html = "index.html",
# These scripts will be included in the JS bundle after require.js
# They should have only named UMD modules, or require.js will throw.
scripts = [
":require.config.js",
":module-id.js",
"@npm//node_modules/tslib:tslib.js",
],
# Serve these files in addition to the JavaScript bundle
# The corresponding <script> or <link> tags will be injected into the index_html
static_files = [
"@npm//node_modules/@angular/material:prebuilt-themes/deeppurple-amber.css",
"@npm//node_modules/zone.js:dist/zone.min.js",
],
# Serve these files but don't inject tags for them into the index file
# This might be because we only want to lazy-load these scripts on-demand,
# or because they aren't compatible with Require.js so we must use a runtime
# loader to load them.
data = [
"@npm//node_modules/@ngrx/store:bundles/store.umd.min.js",
],
# Tell Bazel to build the sources first
deps = ["//src"],
)
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",
],
)
web_package(
name = "prodapp",
# do not sort
assets = [
"@npm//node_modules/@angular/material:prebuilt-themes/deeppurple-amber.css",
"@npm//node_modules/zone.js:dist/zone.min.js",
"@npm//node_modules/systemjs:dist/system.js",
":bundle.min.js",
],
data = [
":bundle",
],
index_html = "index.html",
)
history_server(
name = "prodserver",
data = [":prodapp"],
templated_args = ["src/prodapp"],
)