Skip to content

Commit

Permalink
Merge pull request #309 from brave/component_resources
Browse files Browse the repository at this point in the history
let each component handle its own transpiling
  • Loading branch information
bbondy authored Aug 5, 2018
2 parents dc1e224 + 95d25a5 commit ab75711
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 36 deletions.
18 changes: 18 additions & 0 deletions components/brave_adblock_ui/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import("//brave/components/common/typescript.gni")

transpile_web_ui("brave_adblock_ui") {
inputs = [
"brave_adblock.html",
"brave_adblock.tsx",
"storage.ts",
"store.ts",
"actions/adblock_actions.ts",
"components/app.tsx",
"components/numBlockedStat.tsx",
"components/regionalAdBlockEnabled.tsx",
"constants/adblock_types.ts",
"reducers/adblock_reducer.ts",
]

bundle_name = "brave_adblock.bundle.js"
}
22 changes: 22 additions & 0 deletions components/brave_new_tab_ui/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import("//brave/components/common/typescript.gni")

transpile_web_ui("brave_new_tab_ui") {
inputs = [
"brave_new_tab.html",
"brave_new_tab.tsx",
"storage.ts",
"store.ts",
"actions/new_tab_actions.ts",
"components/app.tsx",
"components/block.tsx",
"components/footerInfo.tsx",
"components/siteRemovalNotification.tsx",
"components/stats.tsx",
"constants/backgrounds.ts",
"constants/new_tab_types.ts",
"constants/theme.ts",
"reducers/index.ts",
"reducers/new_tab_reducer.tsx",
]
bundle_name = "brave_new_tab.bundle.js"
}
17 changes: 17 additions & 0 deletions components/brave_rewards_ui/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import("//brave/components/common/typescript.gni")

transpile_web_ui("brave_rewards_ui") {
inputs = [
"brave_rewards.html",
"brave_rewards.tsx",
"storage.ts",
"store.ts",
"actions/rewards_actions.ts",
"components/app.tsx",
"constants/rewards_types.ts",
"reducers/index.ts",
"reducers/rewards_reducer.ts",
]

bundle_name = "brave_rewards.bundle.js"
}
24 changes: 24 additions & 0 deletions components/brave_welcome_ui/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import("//brave/components/common/typescript.gni")

transpile_web_ui("brave_welcome_ui") {
inputs = [
"brave_welcome.html",
"brave_welcome.tsx",
"storage.ts",
"store.ts",
"actions/welcome_actions.ts",
"components/app.tsx",
"components/braveScreen.tsx",
"components/featuresScreen.tsx",
"components/footer.tsx",
"components/importScreen.tsx",
"components/rewardsScreen.tsx",
"components/shieldsScreen.tsx",
"constants/theme.ts",
"constants/welcome_types.ts",
"reducers/index.ts",
"reducers/welcome_reducer.ts",
]

bundle_name = "brave_welcome.bundle.js"
}
42 changes: 42 additions & 0 deletions components/common/typescript.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
brave_common_typescript_includes = [
rebase_path("classSet.ts"),
rebase_path("debounce.ts"),
rebase_path("locale.ts"),
]

template("transpile_web_ui") {
bundle_name = invoker.bundle_name

action(target_name) {
script = "//brave/script/transpile-web-ui.py"

inputs = brave_common_typescript_includes
if (defined(invoker.inputs)) {
inputs += invoker.inputs
}

output_dir = "$root_gen_dir/brave"

outputs = [
"$output_dir/$bundle_name"
]

gen_dir = rebase_path(output_dir)
args = [
"--target_gen_dir=$gen_dir"
]
if (is_official_build) {
args += [
"--production",
]
}

forward_variables_from(invoker,
[
"deps",
"public_deps",
"testonly",
"visibility",
])
}
}
40 changes: 6 additions & 34 deletions components/resources/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,48 +1,20 @@
import("//tools/grit/grit_rule.gni")

transpile_includes = [
# Brave Adblock Page
"../brave_adblock_ui/brave_adblock.html",
# Brave New Tab
"../brave_new_tab_ui/brave_new_tab.html",
# Brave Rewards
"../brave_rewards_ui/brave_rewards.html",
# Brave Welcome Page
"../brave_welcome_ui/brave_welcome.html"
]

action("transpile_web_uis") {
script = "//brave/script/transpile-web-ui.py"
inputs = transpile_includes
outputs = [
"$target_out_dir/brave_new_tab.bundle.js",
"$target_out_dir/brave_rewards.bundle.js",
"$target_out_dir/brave_welcome.bundle.js",
"$target_out_dir/brave_adblock.bundle.js",
]
gen_dir = rebase_path(root_gen_dir, "//")
args = [
"--target_gen_dir=$gen_dir"
]
if (is_official_build) {
args += [
"--production",
]
}
}

grit("brave_components_resources_grit") {
source = "brave_components_resources.grd"

output_name = "brave_components_resources_new"
inputs = get_target_outputs(":transpile_web_uis")
inputs += transpile_includes

outputs = [
"grit/brave_components_resources.h",
"brave_components_resources.pak",
]
deps = [ ":transpile_web_uis" ]
deps = [
"//brave/components/brave_adblock_ui",
"//brave/components/brave_new_tab_ui",
"//brave/components/brave_rewards_ui",
"//brave/components/brave_welcome_ui",
]
grit_flags = [
"-E",
"root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir),
Expand Down
2 changes: 1 addition & 1 deletion components/webpack/dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
brave_welcome: path.join(__dirname, '../brave_welcome_ui/brave_welcome')
},
output: {
path: path.join(__dirname, '..', '..', '..', process.env.TARGET_GEN_DIR, 'brave'),
path: process.env.TARGET_GEN_DIR,
filename: '[name].bundle.js',
chunkFilename: '[id].chunk.js'
},
Expand Down
2 changes: 1 addition & 1 deletion components/webpack/prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
brave_welcome: path.join(__dirname, '../brave_welcome_ui/brave_welcome')
},
output: {
path: path.join(__dirname, '..', '..', '..', process.env.TARGET_GEN_DIR, 'brave'),
path: process.env.TARGET_GEN_DIR,
filename: '[name].bundle.js',
chunkFilename: '[id].chunk.js'
},
Expand Down

0 comments on commit ab75711

Please sign in to comment.