|
1 | | -# TODO(alexeagle): promote web_package rule to the public API |
2 | | -load("@build_bazel_rules_nodejs//internal/web_package:web_package.bzl", "web_package") |
3 | | -load("@npm//@babel/cli:index.bzl", "babel") |
4 | 1 | load("@npm//http-server:index.bzl", "http_server") |
5 | 2 | load("@npm_bazel_protractor//:index.bzl", "protractor_web_test_suite") |
6 | | -load("@npm_bazel_rollup//:index.bzl", "rollup_bundle") |
7 | | -load("@npm_bazel_terser//:index.bzl", "terser_minified") |
| 3 | +load(":differential_loading.bzl", "differential_loading") |
8 | 4 |
|
9 | | -rollup_bundle( |
10 | | - name = "chunks", |
| 5 | +differential_loading( |
| 6 | + name = "app", |
11 | 7 | srcs = glob(["*.js"]), |
12 | 8 | entry_point = "index.js", |
13 | | - output_dir = True, |
14 | | -) |
15 | | - |
16 | | -# For older browsers, we'll transform the output chunks to es5 + systemjs loader |
17 | | -babel( |
18 | | - name = "chunks_es5", |
19 | | - args = [ |
20 | | - "$(location chunks)", |
21 | | - "--config-file", |
22 | | - "$(location es5.babelrc)", |
23 | | - "--out-dir", |
24 | | - "$@", |
25 | | - ], |
26 | | - data = [ |
27 | | - "chunks", |
28 | | - "es5.babelrc", |
29 | | - "@npm//@babel/preset-env", |
30 | | - ], |
31 | | - output_dir = True, |
32 | | -) |
33 | | - |
34 | | -# Run terser against both modern and legacy browser chunks |
35 | | -terser_minified( |
36 | | - name = "chunks_es5.min", |
37 | | - src = "chunks_es5", |
38 | | -) |
39 | | - |
40 | | -terser_minified( |
41 | | - name = "chunks.min", |
42 | | - src = "chunks", |
43 | | -) |
44 | | - |
45 | | -web_package( |
46 | | - name = "package", |
47 | | - # FIXME: need something like: |
48 | | - # entry_point = "index.js", |
49 | | - assets = [ |
50 | | - "styles.css", |
51 | | - ], |
52 | | - data = [ |
53 | | - "favicon.png", |
54 | | - # For differential loading, we supply both ESModule chunks and es5 chunks. |
55 | | - # The injector will put two complimentary script tags in the index.html |
56 | | - ":chunks.min", |
57 | | - ":chunks_es5.min", |
58 | | - ], |
59 | | - index_html = "index.html", |
60 | 9 | ) |
61 | 10 |
|
62 | 11 | http_server( |
63 | 12 | name = "server", |
64 | | - data = [":package"], |
65 | | - templated_args = ["package"], |
| 13 | + data = [":app"], |
| 14 | + templated_args = ["app"], |
66 | 15 | ) |
67 | 16 |
|
68 | 17 | # BazelCI docker images are missing shares libs to run a subset browser tests: |
|
0 commit comments