| # 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("//tools/grit/preprocess_if_expr.gni") |
| import("//tools/typescript/webui_ts_library.gni") |
| import("//ui/webui/resources/tools/bundle_js.gni") |
| import("//ui/webui/resources/tools/eslint_ts.gni") |
| import("//ui/webui/resources/tools/minify_js.gni") |
| import("//ui/webui/webui_features.gni") |
| |
| ts_files = [ |
| "constants.ts", |
| "neterror.ts", |
| "dino_game/background_el.ts", |
| "dino_game/cloud.ts", |
| "dino_game/constants.ts", |
| "dino_game/dimensions.ts", |
| "dino_game/distance_meter.ts", |
| "dino_game/game_config.ts", |
| "dino_game/game_over_panel.ts", |
| "dino_game/game_state_provider.ts", |
| "dino_game/generated_sound_fx.ts", |
| "dino_game/horizon_line.ts", |
| "dino_game/horizon.ts", |
| "dino_game/image_sprite_provider.ts", |
| "dino_game/night_mode.ts", |
| "dino_game/obstacle.ts", |
| "dino_game/offline.ts", |
| "dino_game/offline_sprite_definitions.ts", |
| "dino_game/sprite_position.ts", |
| "dino_game/trex.ts", |
| "dino_game/utils.ts", |
| ] |
| |
| preprocess_if_expr("preprocess") { |
| visibility = [ |
| ":build_ts", |
| ":lint", |
| ] |
| out_folder = "${target_gen_dir}/preprocessed" |
| in_files = ts_files |
| if (is_ios) { |
| in_files += [ "error_page_controller_ios.js" ] |
| } |
| } |
| |
| webui_ts_library("build_ts") { |
| visibility = [ |
| ":bundle_js_internal", |
| ":lint", |
| ] |
| root_dir = "${target_gen_dir}/preprocessed" |
| out_dir = "$target_gen_dir/tsc" |
| in_files = ts_files |
| deps = [ |
| "//third_party/lit/v3_0:build_ts", |
| "//ui/webui/resources/js:build_ts", |
| ] |
| extra_deps = [ ":preprocess" ] |
| } |
| |
| eslint_ts("lint") { |
| in_folder = "${target_gen_dir}/preprocessed" |
| in_files = ts_files |
| tsconfig = "$target_gen_dir/tsconfig_build_ts.json" |
| deps = [ |
| ":build_ts", |
| ":preprocess", |
| ] |
| } |
| |
| # Generate JS bundles for interstitials UIs. Always bundle regardless of the |
| # `optimize_webui` GN arg, as these UIs can't load any JS modules at runtime, |
| # since they are not proper WebUI pages and therefore are not backed up by any |
| # WebUIDataSource. Use `optimize_webui` only to decide whether to also minify. |
| group("bundle_js") { |
| deps = [ ":lint" ] |
| if (optimize_webui) { |
| public_deps = [ ":minify_js" ] |
| } else { |
| public_deps = [ ":bundle_js_internal" ] |
| } |
| } |
| |
| # Bundle without minifying. |
| bundle_js("bundle_js_internal") { |
| visibility = [ |
| ":bundle_js", |
| ":minify_js", |
| ] |
| |
| # Using a dummy value for`host` which is ignored anyway since the code being |
| # bundled below is not served from any host. |
| host = "_ignored_" |
| input = rebase_path("${target_gen_dir}/tsc", root_build_dir) |
| out_folder = "${target_gen_dir}/bundled" |
| js_module_in_files = [ "neterror.js" ] |
| |
| shared_interstitials_path = |
| rebase_path("${root_gen_dir}/components/security_interstitials/core/", |
| root_build_dir) |
| |
| external_paths = [ "chrome://interstitials/|$shared_interstitials_path" ] |
| deps = [ |
| ":build_ts", |
| "../../security_interstitials/core/common/resources:preprocess", |
| "//third_party/lit/v3_0:build_min_js", |
| ] |
| } |
| |
| if (optimize_webui) { |
| # Bundle and minify. |
| minify_js("minify_js") { |
| visibility = [ ":bundle_js" ] |
| in_folder = "${target_gen_dir}/bundled" |
| out_folder = "${target_gen_dir}/minified" |
| in_files = [ "neterror.rollup.js" ] |
| deps = [ ":bundle_js_internal" ] |
| } |
| } |