Skip to content

Instantly share code, notes, and snippets.

@AurelienLoyer
Last active March 3, 2020 12:19
Show Gist options
  • Save AurelienLoyer/730c8ed22d892e1fd53e8a5255e832e9 to your computer and use it in GitHub Desktop.
Save AurelienLoyer/730c8ed22d892e1fd53e8a5255e832e9 to your computer and use it in GitHub Desktop.
Bazel demo LIVE CODING !
load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "rollup_bundle")
load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package")
load("@npm_bazel_typescript//:index.bzl", "ts_library")
exports_files(["tsconfig.json"])
# compile
ts_library(
name = "app",
srcs = glob(["*.ts","**/*.tsx"]),
deps = [
# "//layout",
"@npm//@types/react",
"@npm//@types/react-dom",
]
)
# rollup
rollup_bundle(
name="rollup",
entry_point=":app.ts",
enable_code_splitting = False,
deps = [
"//:app",
"@npm//react",
"@npm//react-dom",
]
)
# package
web_package(
name="package",
index_html= ":index.html",
assets = [
":rollup.min.js",
":rollup.min.es2015.js"
]
)
# serve
http_server(
name = "serve",
templated_args = [
"package"
],
data = [
":package"
]
)
workspace(
name = "react_beer",
managed_directories = {"@npm": ["node_modules"]},
)
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "da72ea53fa1cb8ab5ef7781ba06b97259b7d579a431ce480476266bc81bdf21d",
url = "https://github.com/bazelbuild/rules_nodejs/releases/download/0.36.2/rules_nodejs-0.36.2.tar.gz",
)
load("@build_bazel_rules_nodejs//:defs.bzl", "yarn_install")
yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)
load("@npm//:install_bazel_dependencies.bzl", "install_bazel_dependencies")
install_bazel_dependencies()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment