blob: 398c4039de55334350a54bca82faffd0461c0226 [file] [log] [blame]
Sean Condondfc6dba2019-11-09 11:50:23 +00001package(default_visibility = ["//visibility:public"])
2
3load("@npm_angular_bazel//:index.bzl", "ng_module")
4load("@npm_bazel_karma//:index.bzl", "ts_web_test_suite")
5load("@build_bazel_rules_nodejs//:defs.bzl", "history_server", "rollup_bundle")
6load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
7load("@npm_bazel_typescript//:index.bzl", "ts_devserver", "ts_library")
8load("@io_bazel_rules_sass//:defs.bzl", "multi_sass_binary", "sass_binary")
9
10sass_binary(
11 name = "global_stylesheet",
12 src = glob([
13 "styles.css",
14 "styles.scss",
15 ])[0],
16 output_name = "global_stylesheet.css",
17)
18
19multi_sass_binary(
20 name = "styles",
21 srcs = glob(
22 include = ["**/*.scss"],
23 exclude = ["styles.scss"],
24 ),
25)
26
27ng_module(
28 name = "src",
29 srcs = glob(
30 include = ["**/*.ts"],
31 exclude = [
32 "**/*.spec.ts",
33 "main.ts",
34 "test.ts",
35 "initialize_testbed.ts",
36 ],
37 ),
38 assets = glob([
39 "**/*.css",
40 "**/*.html",
41 ]) + ([":styles"] if len(glob(["**/*.scss"])) else []),
42 tsconfig = "tsconfig.app.json",
43 deps = [
44 "//web/gui2-fw-lib/projects/gui2-fw-lib",
45 "@npm//@angular/animations",
46 "@npm//@angular/core",
47 "@npm//@angular/platform-browser",
48 "@npm//@angular/router",
49 "@npm//@types",
50 "@npm//rxjs",
51 ],
52)
53
54rollup_bundle(
55 name = "bundle",
56 entry_point = ":main.prod.ts",
57 deps = [
58 "//src",
59 "@npm//@angular/router",
60 "@npm//rxjs",
61 ],
62)
63
64web_package(
65 name = "prodapp",
66 assets = [
67 # do not sort
68 "@npm//:node_modules/zone.js/dist/zone.min.js",
69 ":bundle.min.js",
70 ":global_stylesheet",
71 ],
72 data = [
73 "favicon.ico",
74 ],
75 index_html = "index.html",
76)
77
78history_server(
79 name = "prodserver",
80 data = [":prodapp"],
81 templated_args = ["src/prodapp"],
82)
83
84filegroup(
85 name = "rxjs_umd_modules",
86 srcs = [
87 # do not sort
88 "@npm//:node_modules/rxjs/bundles/rxjs.umd.js",
89 ":rxjs_shims.js",
90 ],
91)
92
93genrule(
94 name = "d3-copy",
95 srcs = ["@npm//:node_modules/d3/dist/d3.js"],
96 outs = ["d3.js"],
97 cmd = "cp $< $@",
98 output_to_bindir = 1,
99)
100
101ts_devserver(
102 name = "devserver",
103 data = [
104 "favicon.ico",
105 ],
106 entry_module = "org_onosproject_onos/web/gui2-fw-lib/src/main.dev",
107 index_html = "index.html",
108 port = 4200,
109 scripts = [
110 "@npm//:node_modules/tslib/tslib.js",
111 ":rxjs_umd_modules",
112 ],
113 serving_path = "/bundle.min.js",
114 static_files = [
115 "@npm//:node_modules/zone.js/dist/zone.min.js",
116 ":global_stylesheet",
117 ":d3-copy",
118 ],
119 deps = [":src"],
120)
121
122ts_library(
123 name = "test_lib",
124 testonly = 1,
125 srcs = glob(["**/*.spec.ts"]),
126 deps = [
127 ":src",
128 "@npm//@angular/core",
129 "@npm//@angular/router",
130 "@npm//@types",
131 ],
132)
133
134ts_library(
135 name = "initialize_testbed",
136 testonly = 1,
137 srcs = [
138 "initialize_testbed.ts",
139 ],
140 deps = [
141 "@npm//@angular/core",
142 "@npm//@angular/platform-browser-dynamic",
143 "@npm//@types",
144 ],
145)
146
147ts_web_test_suite(
148 name = "test",
149 srcs = [
150 "@npm//:node_modules/tslib/tslib.js",
151 ],
152 # do not sort
153 bootstrap = [
154 "@npm//:node_modules/zone.js/dist/zone-testing-bundle.js",
155 "@npm//:node_modules/reflect-metadata/Reflect.js",
156 ],
157 browsers = [
158 "@io_bazel_rules_webtesting//browsers:chromium-local",
159 ],
160 runtime_deps = [
161 ":initialize_testbed",
162 ],
163 deps = [
164 ":rxjs_umd_modules",
165 ":test_lib",
166 "@npm//karma-jasmine",
167 ],
168)