chromium/ui/webui/resources/tools/minify_js.gni

# Copyright 2023 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//third_party/node/node.gni")

template("minify_js") {
  node(target_name) {
    script = "//ui/webui/resources/tools/minify_js.py"
    forward_variables_from(invoker,
                           [
                             "visibility",
                             "deps",
                             "in_folder",
                             "out_folder",
                           ])

    inputs = []
    outputs = []
    foreach(f, invoker.in_files) {
      assert(get_path_info(f, "extension") == "js")
      inputs += [ "$in_folder/$f" ]
      outputs += [ "$out_folder/$f" ]
    }

    out_manifest = "$target_gen_dir/${target_name}_manifest.json"
    if (defined(invoker.out_manifest)) {
      out_manifest = invoker.out_manifest
    }

    outputs += [ out_manifest ]

    args = [
             "--in_folder",
             rebase_path(in_folder, root_build_dir),
             "--out_folder",
             rebase_path(out_folder, root_build_dir),
             "--out_manifest",
             rebase_path(out_manifest, root_build_dir),
             "--in_files",
           ] + invoker.in_files
  }
}