# Copyright 2017 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//ui/webui/resources/tools/bundle_js.gni")
import("//ui/webui/resources/tools/bundle_js_excludes.gni")
import("//ui/webui/resources/tools/minify_js.gni")
template("optimize_webui") {
bundle_js("${target_name}__bundle_js") {
forward_variables_from(invoker,
"*",
[
"excludes",
"visibility",
"out_manifest",
])
excludes = BUNDLE_JS_EXCLUDES
if (defined(invoker.excludes)) {
excludes += invoker.excludes
}
out_folder = "$target_gen_dir/${target_name}_bundled"
visibility = [ ":$target_name" ]
}
minify_js(target_name) {
forward_variables_from(invoker, [ "visibility" ])
in_folder = "$target_gen_dir/${target_name}_bundled"
out_folder = target_gen_dir
in_files = []
js_files = filter_include(get_target_outputs(":${target_name}__bundle_js"),
[ "*.js" ])
foreach(_js_file, js_files) {
in_files += [ string_replace(_js_file,
"$target_gen_dir/${target_name}_bundled/",
"") ]
}
if (defined(invoker.out_manifest)) {
out_manifest = invoker.out_manifest
}
deps = [ ":${target_name}__bundle_js" ]
}
}