blob: b33b098fad01829fb5b0dd34b5f49204953e2c4d [file] [log] [blame]
Sean Condon6a6f9a02020-01-09 14:09:36 +00001"""
2 Copyright ${year}-present Open Networking Foundation
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15"""
16
17package(default_visibility = ["//visibility:public"])
18
Sean Condon6a6f9a02020-01-09 14:09:36 +000019load("@build_bazel_rules_nodejs//:index.bzl", "pkg_web")
20load("@npm//history-server:index.bzl", "history_server")
Sean Condon0bd777c2021-01-01 14:23:29 +000021load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
22load("@npm//@bazel/terser:index.bzl", "terser_minified")
23load("@npm//@bazel/typescript:index.bzl", "ts_devserver", "ts_library")
Sean Condon6a6f9a02020-01-09 14:09:36 +000024load("@io_bazel_rules_sass//:defs.bzl", "multi_sass_binary", "sass_binary")
25
26sass_binary(
27 name = "global_stylesheet",
28 src = glob([
29 "styles.css",
30 "styles.scss",
31 ])[0],
32 output_name = "global_stylesheet.css",
33)
34
35multi_sass_binary(
36 name = "styles",
37 srcs = glob(
38 include = ["**/*.scss"],
39 exclude = ["styles.scss"],
40 ),
41)
42
Sean Condon0bd777c2021-01-01 14:23:29 +000043ts_library(
Sean Condon6a6f9a02020-01-09 14:09:36 +000044 name = "src",
45 srcs = glob(
46 include = ["**/*.ts"],
47 exclude = [
48 "**/*.spec.ts",
49 "main.ts",
50 "test.ts",
51 "initialize_testbed.ts",
52 ],
53 ),
Sean Condon0bd777c2021-01-01 14:23:29 +000054 angular_assets = [
55 "//web/gui2-fw-lib:extra_css",
56 ] + glob([
57 "**/*.css",
58 "**/*.html",
Sean Condon6a6f9a02020-01-09 14:09:36 +000059 ]) + ([":styles"] if len(glob(["**/*.scss"])) else []),
60 generate_ve_shims = True,
Sean Condon0bd777c2021-01-01 14:23:29 +000061 use_angular_plugin = True,
Sean Condon6a6f9a02020-01-09 14:09:36 +000062 deps = [
63 "@npm//@angular/core",
Sean Condon0bd777c2021-01-01 14:23:29 +000064 "@npm//@angular/common",
Sean Condon6a6f9a02020-01-09 14:09:36 +000065 "@npm//@angular/platform-browser",
66 "@npm//@angular/router",
67 "@npm//@types",
68 "@npm//d3",
69 "@npm//gui2-fw-lib",
70 "@npm//rxjs",
71 ],
72)
73
74rollup_bundle(
75 name = "bundle",
76 config_file = "rollup.config.js",
77 entry_point = ":main.prod.ts",
78 deps = [
79 "//src",
80 "@npm//rollup-plugin-commonjs",
81 "@npm//rollup-plugin-node-resolve",
82 ],
83)
84
85terser_minified(
86 name = "bundle.min",
87 src = ":bundle",
88)
89
90pkg_web(
91 name = "prodapp",
92 srcs = [
93 # do not sort
94 "favicon.ico",
95 ":bundle.min",
96 "index.html",
97 ":global_stylesheet",
98 ],
99)
100
101history_server(
102 name = "prodserver",
103 data = [":prodapp"],
104 templated_args = ["src/prodapp"],
105)
106
107filegroup(
108 name = "rxjs_umd_modules",
109 srcs = [
110 # do not sort
111 "@npm//:node_modules/rxjs/bundles/rxjs.umd.js",
112 ":rxjs_shims.js",
113 ],
114)
115
116ts_devserver(
117 name = "devserver",
118 entry_module = "project/src/main.dev",
119 port = 4200,
120 scripts = [
121 "@npm//:node_modules/tslib/tslib.js",
122 ":rxjs_umd_modules",
123 ],
124 serving_path = "/bundle.min.js",
125 static_files = [
126 "@npm//:node_modules/zone.js/dist/zone.min.js",
127 ":global_stylesheet",
128 ],
129 deps = [":src"],
130)
131
132ts_library(
133 name = "test_lib",
134 testonly = 1,
135 srcs = glob(["**/*.spec.ts"]),
136 deps = [
137 ":src",
138 "@npm//@angular/core",
139 "@npm//@angular/router",
140 "@npm//@types",
141 ],
142)
143
144ts_library(
145 name = "initialize_testbed",
146 testonly = 1,
147 srcs = [
148 "initialize_testbed.ts",
149 ],
150 deps = [
151 "@npm//@angular/core",
152 "@npm//@angular/platform-browser-dynamic",
153 "@npm//@types",
154 ],
155)
156
Sean Condon0bd777c2021-01-01 14:23:29 +0000157