| """ |
| Copyright ${year}-present Open Networking Foundation |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| """ |
| |
| package(default_visibility = ["//visibility:public"]) |
| |
| load("@npm_angular_bazel//:index.bzl", "ng_module") |
| load("@npm_bazel_karma//:index.bzl", "karma_web_test_suite") |
| load("@build_bazel_rules_nodejs//:index.bzl", "pkg_web") |
| load("@npm//history-server:index.bzl", "history_server") |
| load("@npm_bazel_rollup//:index.bzl", "rollup_bundle") |
| load("@npm_bazel_terser//:index.bzl", "terser_minified") |
| load("@npm_bazel_typescript//:index.bzl", "ts_devserver", "ts_library") |
| load("@io_bazel_rules_sass//:defs.bzl", "multi_sass_binary", "sass_binary") |
| |
| sass_binary( |
| name = "global_stylesheet", |
| src = glob([ |
| "styles.css", |
| "styles.scss", |
| ])[0], |
| output_name = "global_stylesheet.css", |
| ) |
| |
| multi_sass_binary( |
| name = "styles", |
| srcs = glob( |
| include = ["**/*.scss"], |
| exclude = ["styles.scss"], |
| ), |
| ) |
| |
| ng_module( |
| name = "src", |
| srcs = glob( |
| include = ["**/*.ts"], |
| exclude = [ |
| "**/*.spec.ts", |
| "main.ts", |
| "test.ts", |
| "initialize_testbed.ts", |
| ], |
| ), |
| assets = glob([ |
| "**/*.css", |
| "**/*.html", |
| ]) + ([":styles"] if len(glob(["**/*.scss"])) else []), |
| generate_ve_shims = True, |
| deps = [ |
| "@npm//@angular/core", |
| "@npm//@angular/platform-browser", |
| "@npm//@angular/router", |
| "@npm//@types", |
| "@npm//d3", |
| "@npm//gui2-fw-lib", |
| "@npm//rxjs", |
| ], |
| ) |
| |
| rollup_bundle( |
| name = "bundle", |
| config_file = "rollup.config.js", |
| entry_point = ":main.prod.ts", |
| deps = [ |
| "//src", |
| "@npm//rollup-plugin-commonjs", |
| "@npm//rollup-plugin-node-resolve", |
| ], |
| ) |
| |
| terser_minified( |
| name = "bundle.min", |
| src = ":bundle", |
| ) |
| |
| pkg_web( |
| name = "prodapp", |
| srcs = [ |
| # do not sort |
| "favicon.ico", |
| ":bundle.min", |
| "index.html", |
| ":global_stylesheet", |
| ], |
| ) |
| |
| history_server( |
| name = "prodserver", |
| data = [":prodapp"], |
| templated_args = ["src/prodapp"], |
| ) |
| |
| filegroup( |
| name = "rxjs_umd_modules", |
| srcs = [ |
| # do not sort |
| "@npm//:node_modules/rxjs/bundles/rxjs.umd.js", |
| ":rxjs_shims.js", |
| ], |
| ) |
| |
| ts_devserver( |
| name = "devserver", |
| entry_module = "project/src/main.dev", |
| port = 4200, |
| scripts = [ |
| "@npm//:node_modules/tslib/tslib.js", |
| ":rxjs_umd_modules", |
| ], |
| serving_path = "/bundle.min.js", |
| static_files = [ |
| "@npm//:node_modules/zone.js/dist/zone.min.js", |
| ":global_stylesheet", |
| ], |
| deps = [":src"], |
| ) |
| |
| ts_library( |
| name = "test_lib", |
| testonly = 1, |
| srcs = glob(["**/*.spec.ts"]), |
| deps = [ |
| ":src", |
| "@npm//@angular/core", |
| "@npm//@angular/router", |
| "@npm//@types", |
| ], |
| ) |
| |
| ts_library( |
| name = "initialize_testbed", |
| testonly = 1, |
| srcs = [ |
| "initialize_testbed.ts", |
| ], |
| deps = [ |
| "@npm//@angular/core", |
| "@npm//@angular/platform-browser-dynamic", |
| "@npm//@types", |
| ], |
| ) |
| |
| karma_web_test_suite( |
| name = "test", |
| srcs = [ |
| "@npm//:node_modules/tslib/tslib.js", |
| ], |
| # do not sort |
| bootstrap = [ |
| "@npm//:node_modules/zone.js/dist/zone-testing-bundle.js", |
| "@npm//:node_modules/reflect-metadata/Reflect.js", |
| ], |
| browsers = [ |
| "@io_bazel_rules_webtesting//browsers:firefox-local", |
| ], |
| tags = ["native"], |
| runtime_deps = [ |
| ":initialize_testbed", |
| ], |
| deps = [ |
| ":rxjs_umd_modules", |
| ":test_lib", |
| ], |
| ) |