Skip to content

Commit

Permalink
Add personal_website_web target with javascript support
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansimsmith committed Nov 5, 2024
1 parent a68ace3 commit 70cdb86
Show file tree
Hide file tree
Showing 21 changed files with 1,391 additions and 48 deletions.
5 changes: 4 additions & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
.git
.git/
venv/
node_modules/
personal_website_web/node_modules/
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ bazel-*
**/.terraform/
**/*.tfstate
**/*.tfstate.backup
venv/
**/venv/
**/node_modules/
pnpm-debug.log*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hoist=false
8 changes: 8 additions & 0 deletions .prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const config = {
trailingComma: 'all',
tabWidth: 2,
semi: true,
singleQuote: true,
};

export default config;
13 changes: 13 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_js//js:defs.bzl", "js_library")

npm_link_all_packages(
name = "node_modules",
)

js_library(
name = "prettierrc",
srcs = [".prettier.config.js"],
visibility = ["//tools/format:__pkg__"],
)

alias(
name = "format",
actual = "//tools/format:format",
Expand Down
16 changes: 16 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,19 @@ pip.parse(
requirements_lock = "//:requirements.txt",
)
use_repo(pip, "pypi")

bazel_dep(name = "aspect_rules_js", version = "2.1.0")

pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
use_repo(pnpm, "pnpm")

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm")
npm.npm_translate_lock(
name = "npm",
data = [
"//personal_website_web:package.json",
],
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
)
use_repo(npm, "npm")
131 changes: 85 additions & 46 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"private": true,
"type": "module",
"pnpm": {
"onlyBuiltDependencies": []
},
"dependencies": {
"@vitejs/plugin-react": "^4.3.3",
"globals": "^15.11.0",
"prettier": "^3.3.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"vite": "^5.4.10"
}
}
72 changes: 72 additions & 0 deletions personal_website_web/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
load("@aspect_rules_js//js:defs.bzl", "js_library", "js_run_binary")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:vite/package_json.bzl", "bin")

npm_link_all_packages(
name = "node_modules",
)

js_library(
name = "vite.config",
srcs = ["vite.config.js"],
data = [
"//:node_modules/@vitejs/plugin-react",
"//:node_modules/vite",
],
)

bin.vite_binary(
name = "vite",
chdir = package_name(),
data = [":vite.config"],
)

js_library(
name = "assets",
srcs = glob([
"src/**/*.css",
"src/**/*.svg",
]),
)

js_library(
name = "src",
srcs = glob([
"src/**/*.js",
"src/**/*.jsx",
]),
data = [":assets"],
deps = [
"//:node_modules/react",
"//:node_modules/react-dom",
],
)

filegroup(
name = "public",
srcs = glob(["public/**/*"]),
)

js_run_binary(
name = "build",
srcs =
[
"index.html",
"package.json",
":assets",
":public",
":src",
"//:node_modules/react",
"//:node_modules/react-dom",
],
args = ["build"],
out_dirs = ["dist"],
tool = ":vite",
)

bin.vite_binary(
name = "preview",
args = ["preview"],
chdir = package_name(),
data = [":build"],
)
Loading

0 comments on commit 70cdb86

Please sign in to comment.