diff options
author | Mike Greiling <mike@pixelcog.com> | 2018-04-27 21:00:00 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2018-05-01 23:15:11 +0300 |
commit | 94a9c60eb9b557498849f62b136fcdc49e1d406f (patch) | |
tree | 0b76a9c219d5875802ea4ed8663a0845fcfc4c35 /app/helpers | |
parent | d224b59a769de823e868b115b4631e0cd2d8bb09 (diff) |
combine ancestor entrypoints into child entrypoints instead of importing bundles for each
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/webpack_helper.rb | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/app/helpers/webpack_helper.rb b/app/helpers/webpack_helper.rb index 8f0a3b5b190..2f556559c6b 100644 --- a/app/helpers/webpack_helper.rb +++ b/app/helpers/webpack_helper.rb @@ -6,7 +6,7 @@ module WebpackHelper end def webpack_controller_bundle_tags - bundles = [] + chunks = [] action = case controller.action_name when 'create' then 'new' @@ -15,19 +15,16 @@ module WebpackHelper end route = [*controller.controller_path.split('/'), action].compact + entrypoint = "pages.#{route.join('.')}" - until route.empty? - begin - asset_paths = entrypoint_paths("pages.#{route.join('.')}", extension: 'js') - bundles.unshift(*asset_paths) - rescue Gitlab::Webpack::Manifest::AssetMissingError - # no bundle exists for this path - end - - route.pop + begin + chunks = entrypoint_paths(entrypoint, extension: 'js') + rescue Gitlab::Webpack::Manifest::AssetMissingError + # no bundle exists for this path + chunks = entrypoint_paths("default", extension: 'js') end - javascript_include_tag(*bundles.uniq) + javascript_include_tag(*chunks) end def entrypoint_paths(source, extension: nil, force_same_domain: false) |