| # Copyright 2017 The Bazel Authors. All rights reserved. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| load("@npm//@bazel/concatjs:index.bzl", "concatjs_devserver", "ts_library") |
| load("@npm//@bazel/protractor:index.bzl", "protractor_web_test_suite") |
| |
| ts_library( |
| name = "app", |
| srcs = ["app.ts"], |
| deps = [ |
| "@npm//@types/node", |
| ], |
| ) |
| |
| ts_library( |
| name = "e2e", |
| testonly = 1, |
| srcs = ["app_e2e-spec.ts"], |
| deps = [ |
| "@npm//@types/jasmine", |
| "@npm//@types/node", |
| "@npm//protractor", |
| ], |
| ) |
| |
| concatjs_devserver( |
| name = "devserver", |
| additional_root_paths = [ |
| "npm/node_modules/tslib", |
| "e2e_concatjs_devserver/genrule/devserver/", |
| ], |
| 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", |
| ":show-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 'var el = document.createElement(\"div\"); el.innerText = \"Hello, genrule\"; el.className = \"ts2\"; document.body.appendChild(el);' > $@", |
| ) |
| |
| genrule( |
| name = "show-host", |
| outs = ["test/show-host.js"], |
| cmd = "echo 'var el = document.createElement(\"div\"); el.innerText = location.host; el.className = \"ts3\"; document.body.appendChild(el);' > $@", |
| ) |
| |
| protractor_web_test_suite( |
| name = "devserver_test", |
| on_prepare = "//:protractor.on-prepare.js", |
| server = ":devserver", |
| deps = [":e2e"], |
| ) |