/
BUILD.bazel
122 lines (108 loc) · 2.92 KB
/
BUILD.bazel
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
load("@npm_bazel_typescript//:index.bzl", "ts_devserver", "ts_library")
load("@npm//html-insert-assets:index.bzl", "html_insert_assets")
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_web")
load("@npm_bazel_rollup//:index.bzl", "rollup_bundle")
load("@npm//history-server:index.bzl", "history_server")
load("@npm_bazel_terser//:index.bzl", "terser_minified")
package(default_visibility = [":__subpackages__"])
exports_files(["tsconfig.json"])
inserted_assets = ["@npm//:node_modules/zone.js/dist/zone.min.js"]
static_assets = [":_index.html"] + inserted_assets
filegroup(
name = "rxjs_umd_modules",
srcs = [
":rxjs_shims.js",
"@npm//:node_modules/rxjs/bundles/rxjs.umd.js",
],
)
ts_library(
name = "dev_src",
srcs = ["main.dev.ts"],
tsconfig = ":tsconfig.json",
use_angular_plugin = True,
deps = [
"//app",
"@npm//@angular/compiler-cli",
"@npm//@angular/platform-browser",
],
)
html_insert_assets(
name = "dev_html",
outs = ["index.html"],
args = [
"--html=$(execpath :_index.html)",
"--out=$@",
"--roots=. $(RULEDIR)",
"--assets",
] + ["$(execpath %s)" % s for s in inserted_assets] + ["./_/ts_scripts.js"],
data = static_assets,
)
ts_devserver(
name = "live_server",
entry_module = "bazel_socketio_issue/main.dev",
port = 4200,
scripts = [
"@npm//:node_modules/tslib/tslib.js",
":rxjs_umd_modules",
"@npm//socket.io-client:socket.io-client__umd",
],
static_files = [
":dev_html",
"@npm//:node_modules/zone.js/dist/zone.min.js",
],
deps = [":dev_src"],
)
ts_library(
name = "prod_src",
srcs = ["main.prod.ts"],
tsconfig = ":tsconfig.json",
use_angular_plugin = True,
deps = [
"//app",
"@npm//@angular/compiler-cli",
"@npm//@angular/core",
"@npm//@angular/platform-browser",
],
)
rollup_bundle(
name = "bundle",
config_file = ":rollup.config.js",
entry_points = {
":main.prod.ts": "index.es2015",
},
output_dir = True,
deps = [
":prod_src",
"@npm//rollup-plugin-commonjs",
"@npm//rollup-plugin-node-resolve",
],
)
terser_minified(
name = "bundle.min",
src = ":bundle",
config_file = ":terser.config.json",
)
html_insert_assets(
name = "prod_html",
outs = ["_prod_app/index.html"],
args = [
"--html=$(execpath :_index.html)",
"--out=$@",
"--roots=. $(RULEDIR)",
"--assets",
] + ["$(execpath %s)" % s for s in inserted_assets] + ["$(execpath %s)/index.es2015.js" % ":bundle.min"],
data = [":bundle.min"] + static_assets,
)
pkg_web(
name = "prod_app",
srcs = inserted_assets + [
":prod_html",
":favicon.ico",
":bundle.min",
],
)
history_server(
name = "prod_server",
data = [":prod_app"],
templated_args = ["-a $$(rlocation $(rootpath :prod_app))"],
)