| load("@aspect_rules_webpack//webpack:defs.bzl", "webpack_bundle", "webpack_devserver") |
| load("@npm//:defs.bzl", "npm_link_all_packages") |
| load("@rules_pkg//pkg/private/zip:zip.bzl", "pkg_zip") |
| load("copy_pkg.bzl", "copy_extension_package_to_directory") |
| load("defs.bzl", "browser", "channel") |
| |
| npm_link_all_packages() |
| |
| webpack_srcs = glob([ |
| "src/**", |
| "tsconfig.json", |
| ]) + [ |
| # TODO(https://iavm.xyz/b/twpowertools/256): Move this out of the static |
| # folder. |
| "//src/static:common_console_styles", |
| ] |
| |
| # TODO(https://iavm.xyz/b/twpowertools/256): Remove is_bazel_build once Bazel |
| # replaces Webpack as the build system. |
| webpack_args = ["--env=is_bazel_build=true"] + select({ |
| ":chromium": [ |
| "--env=browser_target=chromium_mv3", |
| ], |
| ":gecko": [ |
| "--env=browser_target=gecko", |
| ], |
| }) + select({ |
| ":canary": [ |
| "--env=canary=true", |
| ], |
| "//conditions:default": [ |
| "--env=canary=false", |
| ], |
| }) |
| |
| webpack_deps = [ |
| ":node_modules/@babel/parser", |
| ":node_modules/@babel/plugin-transform-modules-commonjs", |
| ":node_modules/@babel/traverse", |
| ":node_modules/@babel/types", |
| ":node_modules/@datastructures-js/queue", |
| ":node_modules/@lit-labs/motion", |
| ":node_modules/@lit/localize", |
| ":node_modules/@lit/localize-tools", |
| ":node_modules/@material/banner", |
| ":node_modules/@material/mwc-circular-progress", |
| ":node_modules/@material/mwc-dialog", |
| ":node_modules/@material/tooltip", |
| ":node_modules/@material/web", |
| ":node_modules/@stdlib/utils-escape-regexp-string", |
| ":node_modules/@testing-library/dom", |
| ":node_modules/@types/babel__traverse", |
| ":node_modules/@types/chrome", |
| ":node_modules/@types/node", |
| ":node_modules/@vitest/coverage-v8", |
| ":node_modules/@vitest/eslint-plugin", |
| ":node_modules/@xmldom/xmldom", |
| ":node_modules/async-mutex", |
| ":node_modules/copy-webpack-plugin", |
| ":node_modules/css-loader", |
| ":node_modules/dompurify", |
| ":node_modules/eslint", |
| ":node_modules/google-protobuf", |
| ":node_modules/grpc-web", |
| ":node_modules/html-webpack-plugin", |
| ":node_modules/idb", |
| ":node_modules/jsdom", |
| ":node_modules/json5", |
| ":node_modules/lit", |
| ":node_modules/mini-css-extract-plugin", |
| ":node_modules/path", |
| ":node_modules/poll-until-promise", |
| ":node_modules/prettier", |
| ":node_modules/raw-loader", |
| ":node_modules/sass", |
| ":node_modules/sass-loader", |
| ":node_modules/semver", |
| ":node_modules/style-loader", |
| ":node_modules/sw-xhr", |
| ":node_modules/terser-webpack-plugin", |
| ":node_modules/ts-loader", |
| ":node_modules/ts-node", |
| ":node_modules/typescript", |
| ":node_modules/typescript-eslint", |
| ":node_modules/vitest", |
| ":node_modules/web-ext", |
| ":node_modules/webpack", |
| ":node_modules/webpack-cli", |
| ":node_modules/webpack-preprocessor-loader", |
| ":node_modules/webpack-shell-plugin-next", |
| ] |
| |
| webpack_config = ":webpack.config.js" |
| |
| webpack_bundle( |
| name = "webpack_bundle", |
| srcs = webpack_srcs, |
| args = webpack_args, |
| node_modules = ":node_modules", |
| output_dir = True, |
| webpack_config = webpack_config, |
| deps = webpack_deps, |
| ) |
| |
| copy_extension_package_to_directory( |
| name = "unpacked_pkg", |
| out = "unpacked_pkg", |
| webpack_bundle = ":webpack_bundle", |
| ) |
| |
| pkg_zip( |
| name = "pkg_zip", |
| srcs = [":unpacked_pkg"], |
| out = "twpowertools.zip", |
| strip_prefix = "unpacked_pkg", |
| visibility = ["//visibility:public"], |
| ) |
| |
| browser( |
| name = "browser", |
| build_setting_default = "CHROMIUM", |
| ) |
| |
| channel( |
| name = "channel", |
| build_setting_default = "STABLE", |
| ) |
| |
| config_setting( |
| name = "chromium", |
| flag_values = { |
| ":browser": "CHROMIUM", |
| }, |
| visibility = ["//:__subpackages__"], |
| ) |
| |
| config_setting( |
| name = "gecko", |
| flag_values = { |
| ":browser": "GECKO", |
| }, |
| visibility = ["//:__subpackages__"], |
| ) |
| |
| config_setting( |
| name = "stable", |
| flag_values = { |
| ":channel": "STABLE", |
| }, |
| visibility = ["//:__subpackages__"], |
| ) |
| |
| config_setting( |
| name = "beta", |
| flag_values = { |
| ":channel": "BETA", |
| }, |
| visibility = ["//:__subpackages__"], |
| ) |
| |
| config_setting( |
| name = "canary", |
| flag_values = { |
| ":channel": "CANARY", |
| }, |
| visibility = ["//:__subpackages__"], |
| ) |