diff --git a/.circleci/config.yml b/.circleci/config.yml index cb0ff18eaa..288104d15b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -69,6 +69,9 @@ jobs: - store_artifacts: path: dist/bin/packages/core/test/bundling/hello_world/bundle.min.js destination: packages/core/test/bundling/hello_world/bundle.min.js + - store_artifacts: + path: dist/bin/packages/core/test/bundling/hello_world/bundle.min.js.brotli + destination: packages/core/test/bundling/hello_world/bundle.min.js.brotli - save_cache: key: *cache_key diff --git a/WORKSPACE b/WORKSPACE index c6034a4877..83d244fd33 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -68,3 +68,10 @@ git_repository( remote = "https://github.com/angular/devkit.git", commit = "69fcdee61c5ff3f08aa609dec69155dfd29c809a", ) + +http_archive( + name = "org_brotli", + url = "https://github.com/google/brotli/archive/v1.0.2.zip", + strip_prefix = "brotli-1.0.2", + sha256 = "b43d5d6bc40f2fa6c785b738d86c6bbe022732fe25196ebbe43b9653a025920d", +) diff --git a/packages/bazel/src/ng_rollup_bundle.bzl b/packages/bazel/src/ng_rollup_bundle.bzl index 9900e46794..003d313942 100644 --- a/packages/bazel/src/ng_rollup_bundle.bzl +++ b/packages/bazel/src/ng_rollup_bundle.bzl @@ -26,6 +26,14 @@ PLUGIN_CONFIG="{sideEffectFreeModules: [\n%s]}" % ",\n".join( BO_ROLLUP="angular_devkit/packages/angular_devkit/build_optimizer/src/build-optimizer/rollup-plugin.js" BO_PLUGIN="require('%s').default(%s)" % (BO_ROLLUP, PLUGIN_CONFIG) +def run_brotli(ctx, input, output): + ctx.action( + executable = ctx.executable._brotli, + inputs = [input], + outputs = [output], + arguments = ["--output=%s" % output.path, input.path], + ) + def _ng_rollup_bundle(ctx): # We don't expect anyone to make use of this bundle yet, but it makes this rule # compatible with rollup_bundle which allows them to be easily swapped back and @@ -52,6 +60,8 @@ def _ng_rollup_bundle(ctx): run_uglify(ctx, ctx.outputs.build_es5, ctx.outputs.build_es5_min) run_uglify(ctx, ctx.outputs.build_es5, ctx.outputs.build_es5_min_debug, debug = True) + run_brotli(ctx, ctx.outputs.build_es5_min, ctx.outputs.build_es5_min_compressed) + return DefaultInfo(files=depset([ctx.outputs.build_es5_min])) ng_rollup_bundle = rule( @@ -63,8 +73,14 @@ ng_rollup_bundle = rule( ]), "_rollup": attr.label( executable = True, - cfg="host", + cfg = "host", default = Label("@angular//packages/bazel/src:rollup_with_build_optimizer")), + "_brotli": attr.label( + executable = True, + cfg = "host", + default = Label("@org_brotli//:brotli")), }), - outputs = ROLLUP_OUTPUTS, -) \ No newline at end of file + outputs = dict(ROLLUP_OUTPUTS, **{ + "build_es5_min_compressed": "%{name}.min.js.brotli", + }), +) diff --git a/packages/core/test/bundling/hello_world/BUILD.bazel b/packages/core/test/bundling/hello_world/BUILD.bazel index 08a739f3fc..3fddbe7d3b 100644 --- a/packages/core/test/bundling/hello_world/BUILD.bazel +++ b/packages/core/test/bundling/hello_world/BUILD.bazel @@ -39,6 +39,7 @@ jasmine_node_test( data = [ ":bundle", ":bundle.js", + ":bundle.min.js.brotli", ":bundle.min_debug.js", ], deps = [":test_lib"],