anki/ts/deck-options/BUILD.bazel
Henrik Giesel 24af5bada3 More uniform file naming
kebap-case for .ts, .scss, .html, and directories
2021-07-01 12:24:16 +02:00

155 lines
3.1 KiB
Python

load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("//ts:prettier.bzl", "prettier_test")
load("//ts:eslint.bzl", "eslint_test")
load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte", "svelte_check")
load("//ts:esbuild.bzl", "esbuild")
load("//ts:vendor.bzl", "copy_bootstrap_icons")
load("//ts:compile_sass.bzl", "compile_sass")
load("//ts:jest.bzl", "jest_test")
compile_sass(
srcs = ["deck-options-base.scss"],
group = "base_css",
visibility = ["//visibility:public"],
deps = [
"//ts/sass:base_lib",
"//ts/sass:scrollbar_lib",
"//ts/sass/bootstrap",
],
)
svelte_files = glob(["*.svelte"])
svelte_names = [f.replace(".svelte", "") for f in svelte_files]
compile_svelte(
name = "svelte",
srcs = svelte_files,
deps = [
"//ts/sveltelib",
"//ts/components",
"@npm//@types/bootstrap",
"@npm//@types/marked",
],
)
copy_bootstrap_icons(
name = "bootstrap-icons",
icons = [
"arrow-counterclockwise.svg",
"info-circle.svg",
"gear.svg",
],
)
ts_library(
name = "index",
srcs = ["index.ts"],
deps = [
"DeckOptionsPage",
"lib",
"//ts/lib",
"//ts/components",
"@npm//@popperjs",
"@npm//svelte2tsx",
],
)
ts_library(
name = "lib",
srcs = [
"icons.ts",
"lib.ts",
"steps.ts",
"strings.ts",
],
module_name = "deckoptions",
deps = [
"//ts:image_module_support",
"//ts/lib",
"//ts/lib:backend_proto",
"//ts/sveltelib",
"//ts/components",
"@npm//lodash-es",
"@npm//svelte",
],
)
esbuild(
name = "deck-options",
srcs = [
"//ts:protobuf-shim.js",
],
args = [
"--global-name=anki",
"--inject:$(location //ts:protobuf-shim.js)",
"--resolve-extensions=.mjs,.js",
"--log-level=warning",
"--loader:.svg=text",
],
entry_point = "index.ts",
external = [
"protobufjs/light",
],
output_css = "deck-options.css",
visibility = ["//visibility:public"],
deps = [
"index",
":bootstrap-icons",
":base_css",
"@npm//bootstrap",
"@npm//marked",
"//ts/lib",
"//ts/lib:backend_proto",
"//ts/sveltelib",
"//ts/components",
"//ts/components:svelte_components",
] + svelte_names,
)
exports_files(["deck-options.html"])
# Tests
################
prettier_test(
name = "format_check",
srcs = glob([
"*.ts",
"*.svelte",
]),
)
eslint_test(
name = "eslint",
srcs = glob([
"*.ts",
]),
)
svelte_check(
name = "svelte_check",
srcs = glob([
"*.ts",
"*.svelte",
]) + [
"//ts/sass:button_mixins_lib",
"//ts/sass:night_mode_lib",
"//ts/sass/bootstrap",
"@npm//@types/bootstrap",
"@npm//@types/lodash-es",
"@npm//@types/marked",
"//ts/components",
],
)
jest_test(
protobuf = True,
deps = [
":lib",
"//ts/lib:backend_proto",
"@npm//protobufjs",
"@npm//svelte",
],
)