anki/ts/editor/BUILD.bazel

180 lines
3.7 KiB
Python
Raw Normal View History

2021-01-31 14:15:03 +01:00
load("@npm//@bazel/typescript:index.bzl", "ts_library")
2021-04-27 23:08:47 +02:00
load("//ts/svelte:svelte.bzl", "compile_svelte", "svelte_check")
2021-01-31 14:15:03 +01:00
load("//ts:prettier.bzl", "prettier_test")
load("//ts:eslint.bzl", "eslint_test")
load("//ts:esbuild.bzl", "esbuild")
load("//ts:vendor.bzl", "copy_bootstrap_icons", "copy_mdi_icons")
load("//ts:compile_sass.bzl", "compile_sass")
2021-01-31 19:03:40 +01:00
2021-04-27 23:08:47 +02:00
svelte_files = glob(["*.svelte"])
svelte_names = [f.replace(".svelte", "") for f in svelte_files]
filegroup(
name = "svelte_components",
srcs = svelte_names,
visibility = ["//visibility:public"],
)
compile_svelte(
name = "svelte",
srcs = svelte_files,
visibility = ["//visibility:public"],
deps = [
"//ts/components",
],
2021-04-27 23:08:47 +02:00
)
compile_sass(
srcs = [
"editable.scss",
],
group = "editable_scss",
visibility = ["//visibility:public"],
deps = [
"//ts/sass:scrollbar_lib",
2021-07-05 12:45:44 +02:00
"//ts/sass/codemirror",
],
)
compile_sass(
srcs = [
"fields.scss",
],
group = "base_css",
visibility = ["//visibility:public"],
deps = [
"//ts/sass:base_lib",
"//ts/sass:buttons_lib",
"//ts/sass:scrollbar_lib",
],
2021-01-31 19:03:40 +01:00
)
2021-01-31 14:15:03 +01:00
2021-04-27 23:08:47 +02:00
compile_sass(
srcs = [
"bootstrap.scss",
"legacy.scss",
],
group = "local_css",
visibility = ["//visibility:public"],
2021-04-27 23:08:47 +02:00
deps = [
"//ts/sass:button_mixins_lib",
"//ts/sass/bootstrap",
],
)
2021-01-31 14:15:03 +01:00
ts_library(
name = "editor_ts",
srcs = glob(["*.ts"]),
tsconfig = "//ts:tsconfig.json",
2021-01-31 14:15:03 +01:00
deps = [
"//ts/lib",
"//ts/sveltelib",
2021-04-27 23:08:47 +02:00
"//ts/components",
"//ts/html-filter",
"//ts:image_module_support",
"@npm//svelte",
2021-06-17 14:44:03 +02:00
"@npm//@types/codemirror",
"@npm//codemirror",
2021-05-06 23:04:38 +02:00
] + svelte_names,
2021-01-31 14:15:03 +01:00
)
2021-03-28 18:47:06 +02:00
copy_bootstrap_icons(
name = "bootstrap-icons",
icons = [
"pin-angle.svg",
# inline formatting
"type-bold.svg",
"type-italic.svg",
"type-underline.svg",
"eraser.svg",
"square-fill.svg",
"paperclip.svg",
"mic.svg",
# block formatting
"list-ul.svg",
"list-ol.svg",
"text-paragraph.svg",
"justify.svg",
"text-left.svg",
"text-right.svg",
"text-center.svg",
"text-indent-left.svg",
"text-indent-right.svg",
],
visibility = ["//visibility:public"],
)
copy_mdi_icons(
name = "mdi-icons",
icons = [
"format-superscript.svg",
"format-subscript.svg",
"function-variant.svg",
2021-07-01 11:46:39 +02:00
"contain.svg",
"xml.svg",
2021-05-30 20:09:09 +02:00
"format-color-text.svg",
"format-color-highlight.svg",
"color-helper.svg",
],
visibility = ["//visibility:public"],
)
esbuild(
2021-01-31 14:15:03 +01:00
name = "editor",
args = [
"--loader:.svg=text",
2021-04-07 06:53:53 +02:00
"--resolve-extensions=.mjs,.js",
"--log-level=warning",
],
entry_point = "index_wrapper.ts",
output_css = "editor.css",
2021-01-31 14:15:03 +01:00
visibility = ["//visibility:public"],
deps = [
"editor_ts",
"base_css",
2021-04-27 23:08:47 +02:00
"local_css",
"bootstrap-icons",
"mdi-icons",
2021-04-27 23:08:47 +02:00
"svelte_components",
"//ts/components",
2021-04-27 23:08:47 +02:00
"//ts/components:svelte_components",
"@npm//protobufjs",
2021-01-31 14:15:03 +01:00
],
)
# Tests
################
prettier_test(
name = "format_check",
srcs = glob([
"*.ts",
2021-05-18 14:13:11 +02:00
"*.svelte",
2021-01-31 14:15:03 +01:00
]),
)
2021-05-06 23:33:28 +02:00
eslint_test(
name = "eslint",
srcs = glob(
[
"*.ts",
],
),
)
2021-04-27 23:08:47 +02:00
svelte_check(
name = "svelte_check",
srcs = glob([
"*.ts",
"*.svelte",
]) + [
"//ts/sass:button_mixins_lib",
"//ts/sass/bootstrap",
2021-05-06 23:04:38 +02:00
"@npm//@types/bootstrap",
2021-06-18 03:12:02 +02:00
"//ts/components",
2021-04-27 23:08:47 +02:00
],
)