...

Text file src/edge-infra.dev/pkg/edge/api/graphiql/BUILD.bazel

Documentation: edge-infra.dev/pkg/edge/api/graphiql

     1load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
     2load("@aspect_rules_js//js:defs.bzl", "js_run_devserver")
     3load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
     4load("@npm//:defs.bzl", "npm_link_all_packages")
     5load("@npm//:react-scripts/package_json.bzl", cra_bin = "bin")
     6load("@rules_pkg//:pkg.bzl", "pkg_tar")
     7load("//pkg/edge/api/graphiql:copy_build.bzl", "copy_build")
     8
     9package(default_visibility = ["//visibility:public"])
    10
    11npm_link_all_packages(name = "node_modules")
    12
    13copy_to_bin(
    14    name = "copy_env",
    15    srcs = [
    16        ".env",
    17    ],
    18)
    19
    20CRA_DEPS = [
    21    "//pkg/edge/api/graphiql/src",
    22    "//pkg/edge/api/graphiql/public",
    23    "//pkg/edge/api/graphiql:package.json",
    24    "graphiql_tsconfig",
    25    "//:tsconfig",
    26    ":node_modules/react-scripts",
    27    ":node_modules/react",
    28    ":node_modules/react-dom",
    29    ":node_modules/graphql",
    30    ":node_modules/graphiql",
    31    ":node_modules/@graphiql/plugin-explorer",
    32    ":node_modules/lodash",
    33    ":node_modules/typescript",
    34    ":node_modules/@types",
    35]
    36
    37DEV_DEPS = CRA_DEPS + ["copy_env"]
    38
    39cra_bin.react_scripts(
    40    # Note: If you want to change the name make sure you update BUILD_PATH below accordingly
    41    # https://create-react-app.dev/docs/advanced-configuration/
    42    name = "build",
    43    srcs = CRA_DEPS,
    44    args = ["build"],
    45    chdir = package_name(),
    46    env = {
    47        "BUILD_PATH": "./build",
    48    },
    49    out_dirs = ["build"],
    50)
    51
    52pkg_tar(
    53    name = "tar",
    54    srcs = [":build"],
    55    package_dir = "graphiql",
    56    strip_prefix = ".",  # can you believe that this maintains the folder structure and doesnt flatten it?
    57    visibility = ["//visibility:public"],
    58)
    59
    60js_run_devserver(
    61    name = "start",
    62    args = ["start"],
    63    chdir = package_name(),
    64    command = "node_modules/.bin/react-scripts",
    65    data = DEV_DEPS,
    66    tags = [
    67        # This tag instructs ibazel to pipe into stdin a event describing actions.
    68        # ibazel send EOF to stdin by default and `react-scripts start` will stop when getting EOF in stdin.
    69        # So use this to prevent EOF.
    70        "ibazel_notify_changes",
    71    ],
    72)
    73
    74ts_config(
    75    name = "graphiql_tsconfig",
    76    src = "//pkg/edge/api/graphiql:tsconfig.json",
    77    visibility = ["//visibility:public"],
    78)
    79
    80copy_build(
    81    name = "copy_bundle",
    82    out_path = "hack/graphiql/react",
    83    src_path = ":build",
    84)

View as plain text