Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
94a9c60e
Commit
94a9c60e
authored
Apr 27, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
combine ancestor entrypoints into child entrypoints instead of importing bundles for each
parent
d224b59a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
13 deletions
+26
-13
app/helpers/webpack_helper.rb
app/helpers/webpack_helper.rb
+8
-11
config/webpack.config.js
config/webpack.config.js
+18
-2
No files found.
app/helpers/webpack_helper.rb
View file @
94a9c60e
...
...
@@ -6,7 +6,7 @@ module WebpackHelper
end
def
webpack_controller_bundle_tags
bundle
s
=
[]
chunk
s
=
[]
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
)
...
...
config/webpack.config.js
View file @
94a9c60e
...
...
@@ -25,6 +25,7 @@ const defaultEntries = ['./webpack', './commons', './main'];
function
generateEntries
()
{
// generate automatic entry points
const
autoEntries
=
{};
const
autoEntriesMap
=
{};
const
pageEntries
=
glob
.
sync
(
'
pages/**/index.js
'
,
{
cwd
:
path
.
join
(
ROOT_PATH
,
'
app/assets/javascripts
'
),
});
...
...
@@ -33,14 +34,29 @@ function generateEntries() {
function
generateAutoEntries
(
path
,
prefix
=
'
.
'
)
{
const
chunkPath
=
path
.
replace
(
/
\/
index
\.
js$/
,
''
);
const
chunkName
=
chunkPath
.
replace
(
/
\/
/g
,
'
.
'
);
autoEntries
[
chunkName
]
=
defaultEntries
.
concat
(
`
${
prefix
}
/
${
path
}
`
)
;
autoEntries
Map
[
chunkName
]
=
`
${
prefix
}
/
${
path
}
`
;
}
pageEntries
.
forEach
(
path
=>
generateAutoEntries
(
path
));
autoEntriesCount
=
Object
.
keys
(
autoEntries
).
length
;
const
autoEntryKeys
=
Object
.
keys
(
autoEntriesMap
);
autoEntriesCount
=
autoEntryKeys
.
length
;
// import ancestor entrypoints within their children
autoEntryKeys
.
forEach
(
entry
=>
{
const
entryPaths
=
[
autoEntriesMap
[
entry
]];
const
segments
=
entry
.
split
(
'
.
'
);
while
(
segments
.
pop
())
{
const
ancestor
=
segments
.
join
(
'
.
'
);
if
(
autoEntryKeys
.
includes
(
ancestor
))
{
entryPaths
.
unshift
(
autoEntriesMap
[
ancestor
]);
}
}
autoEntries
[
entry
]
=
defaultEntries
.
concat
(
entryPaths
);
});
const
manualEntries
=
{
default
:
defaultEntries
,
raven
:
'
./raven/index.js
'
,
ide
:
'
./ide/index.js
'
,
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment