Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In fitbit challenges frontend, use webpack to build everything #157

Merged
merged 8 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ pg_dump.sql

# JS
fitbit_challenges/frontend/node_modules
.aspect
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,4 @@ bazel-out
bazel-monorepo
bazel-rules
bazel-testlogs
.aspect/
2 changes: 2 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,5 @@ rules_ts_ext.deps()
use_repo(rules_ts_ext, "npm_typescript")

bazel_dep(name = "aspect_rules_jest", version = "0.21.0")

bazel_dep(name = "aspect_rules_webpack", version = "0.15.0")
2 changes: 2 additions & 0 deletions MODULE.bazel.lock

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

90 changes: 65 additions & 25 deletions fitbit_challenges/frontend/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,54 +1,94 @@
load("@aspect_rules_jest//jest:defs.bzl", "jest_test")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_rules_webpack//webpack:defs.bzl", "webpack_bundle")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//fitbit_challenges/frontend:tailwindcss/package_json.bzl", tailwindcss_bin = "bin")

npm_link_all_packages(name = "node_modules")

TYPE_DEPS = [
":node_modules/@types/jest",
":node_modules/@types/lodash",
":node_modules/@types/node",
":node_modules/@types/react",
":node_modules/@types/react-dom",
]

TEST_DEPS = [
":node_modules/@apollo/react-testing",
":node_modules/@testing-library/jest-dom",
":node_modules/@testing-library/react",
":node_modules/jest-environment-jsdom",
":node_modules/jsdom",
]

BUILD_DEPS = [
":node_modules/@apollo/client",
":node_modules/lodash",
":node_modules/react",
":node_modules/react-canvas-confetti",
":node_modules/react-dom",
":node_modules/react-router-dom",
]

tailwindcss_bin.tailwindcss(
name = "tailwindcss",
srcs = [
"src/App.src.css",
":tailwind.config.js",
":node_modules/tailwindcss",
],
outs = [
"src/App.css",
],
args = [
"--config fitbit_challenges/frontend/tailwind.config.js",
"-i fitbit_challenges/frontend/src/App.src.css",
"-o fitbit_challenges/frontend/src/App.css"
],
log_level = "debug",
)

ts_project(
name = "ts",
allow_js = True,
assets = [
"src/App.src.css",
"src/index.css",
# "src/index.css",
"src/logo.svg",
"src/components/fitbit.png",
"src/components/logo192.png",
],
out_dir = ".",
resolve_json_module = True,
transpiler = "tsc",
deps = [
":node_modules/@apollo/client",
":node_modules/@apollo/react-testing",
":node_modules/@testing-library/jest-dom",
":node_modules/@testing-library/react",
":node_modules/@types/jest",
":node_modules/@types/lodash",
":node_modules/@types/node",
":node_modules/@types/react",
":node_modules/@types/react-dom",
":node_modules/lodash",
":node_modules/react-dom",
":node_modules/react-router-dom",
deps = BUILD_DEPS + TEST_DEPS + TYPE_DEPS,
)

webpack_bundle(
name = "webpack",
node_modules = ":node_modules",
srcs = glob(["public/**/*"]) + [":ts", ":tailwindcss"],
entry_point = "src/index.js",
deps = BUILD_DEPS + [
":node_modules/copy-webpack-plugin",
":node_modules/css-loader",
":node_modules/file-loader",
":node_modules/html-webpack-plugin",
":node_modules/process",
":node_modules/style-loader",
],
chdir = package_name(),
webpack_config = ":webpack.config.js",
output_dir = True,
)

jest_test(
name = "test",
config = "jest.config.json",
data = [
"package.json",
":node_modules/@apollo/client",
":node_modules/@apollo/react-testing",
":node_modules/@testing-library/jest-dom",
":node_modules/@testing-library/react",
":node_modules/jest-environment-jsdom",
":node_modules/jsdom",
":node_modules/lodash",
":node_modules/react",
":node_modules/react-canvas-confetti",
":node_modules/react-router-dom",
] + [
] + BUILD_DEPS + TEST_DEPS + [
"mocks/fileMock.js",
"src/DateUtils.js",
"src/DateUtils.test.js",
Expand Down
Loading