| load("//:defs.bzl", "ts_devserver") |
| load("//internal:defaults.bzl", "ts_library") |
| |
| ts_library( |
| name = "app", |
| srcs = ["app.ts"], |
| tsconfig = "//examples:tsconfig.json", |
| deps = [ |
| "@npm//@types/node", |
| ], |
| ) |
| |
| ts_devserver( |
| name = "devserver", |
| additional_root_paths = [ |
| "npm/node_modules/tslib", |
| "npm_bazel_typescript/examples/devserver/", |
| ], |
| port = 80, |
| serving_path = "/bundle.js", |
| static_files = [ |
| # Files you want to import from the "additional_root_paths", still need to be explicitly specified |
| # as files that should be served. The root paths just make it more convenient to import those dependencies. |
| "@npm//tslib", |
| ":say-hello", |
| ":print-host", |
| ":index.html", |
| ], |
| # Dependencies that produce JavaScript output will be automatically picked up by ConcatJS and will be |
| # part of the serving_path bundle. |
| deps = [":app"], |
| ) |
| |
| genrule( |
| name = "say-hello", |
| outs = ["say-hello.js"], |
| cmd = "echo 'console.log(\"Hello!\")' > $@", |
| ) |
| |
| genrule( |
| name = "print-host", |
| outs = ["test/print-host.js"], |
| cmd = "echo 'console.log(location.host)' > $@", |
| ) |