| # An example/repro of https://github.com/aspect-build/rules_js/issues/656 |
| # using vite v6 and react |
| |
| load("@aspect_rules_js//js:defs.bzl", "js_library") |
| load("@bazel_skylib//rules:build_test.bzl", "build_test") |
| load("@npm//:defs.bzl", "npm_link_all_packages") |
| load("@npm//vite6:vite/package_json.bzl", vite_bin = "bin") |
| |
| npm_link_all_packages(name = "node_modules") |
| |
| js_library( |
| name = "vite-config", |
| srcs = ["vite.config.mjs"], |
| deps = [ |
| ":node_modules/@vitejs/plugin-react", |
| ":node_modules/vite", |
| ], |
| ) |
| |
| vite_bin.vite( |
| name = "build", |
| srcs = [ |
| "index.html", |
| "src/index.jsx", |
| ":node_modules/react", |
| ":node_modules/react-dom", |
| ], |
| chdir = package_name(), |
| data = [":vite-config"], |
| fixed_args = [ |
| "build", |
| "--config", |
| "$$RUNFILES_DIR/$(rlocationpath :vite-config)", |
| ], |
| out_dirs = ["build"], |
| ) |
| |
| build_test( |
| name = "build_test", |
| targets = [":build"], |
| ) |