blob: 398c4039de55334350a54bca82faffd0461c0226 [file] [log] [blame]
package(default_visibility = ["//visibility:public"])
load("@npm_angular_bazel//:index.bzl", "ng_module")
load("@npm_bazel_karma//:index.bzl", "ts_web_test_suite")
load("@build_bazel_rules_nodejs//:defs.bzl", "history_server", "rollup_bundle")
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
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 []),
tsconfig = "tsconfig.app.json",
deps = [
"//web/gui2-fw-lib/projects/gui2-fw-lib",
"@npm//@angular/animations",
"@npm//@angular/core",
"@npm//@angular/platform-browser",
"@npm//@angular/router",
"@npm//@types",
"@npm//rxjs",
],
)
rollup_bundle(
name = "bundle",
entry_point = ":main.prod.ts",
deps = [
"//src",
"@npm//@angular/router",
"@npm//rxjs",
],
)
web_package(
name = "prodapp",
assets = [
# do not sort
"@npm//:node_modules/zone.js/dist/zone.min.js",
":bundle.min.js",
":global_stylesheet",
],
data = [
"favicon.ico",
],
index_html = "index.html",
)
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",
],
)
genrule(
name = "d3-copy",
srcs = ["@npm//:node_modules/d3/dist/d3.js"],
outs = ["d3.js"],
cmd = "cp $< $@",
output_to_bindir = 1,
)
ts_devserver(
name = "devserver",
data = [
"favicon.ico",
],
entry_module = "org_onosproject_onos/web/gui2-fw-lib/src/main.dev",
index_html = "index.html",
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",
":d3-copy",
],
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",
],
)
ts_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:chromium-local",
],
runtime_deps = [
":initialize_testbed",
],
deps = [
":rxjs_umd_modules",
":test_lib",
"@npm//karma-jasmine",
],
)