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
6ddd2f4a
Commit
6ddd2f4a
authored
Feb 26, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert config.entry into an function
parent
d9b95d9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
25 deletions
+31
-25
config/webpack.config.js
config/webpack.config.js
+31
-25
No files found.
config/webpack.config.js
View file @
6ddd2f4a
...
...
@@ -21,33 +21,29 @@ var DEV_SERVER_LIVERELOAD = process.env.DEV_SERVER_LIVERELOAD !== 'false';
var
WEBPACK_REPORT
=
process
.
env
.
WEBPACK_REPORT
;
var
NO_COMPRESSION
=
process
.
env
.
NO_COMPRESSION
;
// generate automatic entry points
var
autoEntries
=
{};
var
pageEntries
=
glob
.
sync
(
'
pages/**/index.js
'
,
{
cwd
:
path
.
join
(
ROOT_PATH
,
'
app/assets/javascripts
'
)
});
function
generateAutoEntries
(
path
,
prefix
=
'
.
'
)
{
const
chunkPath
=
path
.
replace
(
/
\/
index
\.
js$/
,
''
);
const
chunkName
=
chunkPath
.
replace
(
/
\/
/g
,
'
.
'
);
autoEntries
[
chunkName
]
=
`
${
prefix
}
/
${
path
}
`
;
}
function
generateEntries
()
{
// generate automatic entry points
var
autoEntries
=
{};
var
pageEntries
=
glob
.
sync
(
'
pages/**/index.js
'
,
{
cwd
:
path
.
join
(
ROOT_PATH
,
'
app/assets/javascripts
'
)
});
function
generateAutoEntries
(
path
,
prefix
=
'
.
'
)
{
const
chunkPath
=
path
.
replace
(
/
\/
index
\.
js$/
,
''
);
const
chunkName
=
chunkPath
.
replace
(
/
\/
/g
,
'
.
'
);
autoEntries
[
chunkName
]
=
`
${
prefix
}
/
${
path
}
`
;
}
pageEntries
.
forEach
((
path
)
=>
generateAutoEntries
(
path
));
pageEntries
.
forEach
((
path
)
=>
generateAutoEntries
(
path
));
// add and replace any ce entries with ee entries
const
eePageEntries
=
glob
.
sync
(
'
pages/**/index.js
'
,
{
cwd
:
path
.
join
(
ROOT_PATH
,
'
ee/app/assets/javascripts
'
)
});
eePageEntries
.
forEach
((
path
)
=>
generateAutoEntries
(
path
,
'
ee
'
));
const
eePageEntries
=
glob
.
sync
(
'
pages/**/index.js
'
,
{
cwd
:
path
.
join
(
ROOT_PATH
,
'
ee/app/assets/javascripts
'
)
});
eePageEntries
.
forEach
((
path
)
=>
generateAutoEntries
(
path
,
'
ee
'
));
// report our auto-generated bundle count
var
autoEntriesCount
=
Object
.
keys
(
autoEntries
).
length
;
console
.
log
(
`
${
autoEntriesCount
}
entries from '/pages' automatically added to webpack output.`
);
// report our auto-generated bundle count
if
(
IS_DEV_SERVER
)
{
var
autoEntriesCount
=
Object
.
keys
(
autoEntries
).
length
;
console
.
log
(
`
${
autoEntriesCount
}
entries from '/pages' automatically added to webpack output.`
);
}
var
config
=
{
// because sqljs requires fs.
node
:
{
fs
:
"
empty
"
},
context
:
path
.
join
(
ROOT_PATH
,
'
app/assets/javascripts
'
),
entry
:
{
const
manualEntries
=
{
balsamiq_viewer
:
'
./blob/balsamiq_viewer.js
'
,
cycle_analytics
:
'
./cycle_analytics/cycle_analytics_bundle.js
'
,
commit_pipelines
:
'
./commit/pipelines/pipelines_bundle.js
'
,
...
...
@@ -105,7 +101,19 @@ var config = {
service_desk_issues
:
'
ee/service_desk_issues/index.js
'
,
roadmap
:
'
ee/roadmap
'
,
ee_sidebar
:
'
ee/sidebar/sidebar_bundle.js
'
,
};
return
Object
.
assign
(
manualEntries
,
autoEntries
);
}
var
config
=
{
// because sqljs requires fs.
node
:
{
fs
:
"
empty
"
},
context
:
path
.
join
(
ROOT_PATH
,
'
app/assets/javascripts
'
),
entry
:
generateEntries
,
output
:
{
path
:
path
.
join
(
ROOT_PATH
,
'
public/assets/webpack
'
),
...
...
@@ -334,8 +342,6 @@ var config = {
}
}
config
.
entry
=
Object
.
assign
({},
autoEntries
,
config
.
entry
);
if
(
IS_PRODUCTION
)
{
config
.
devtool
=
'
source-map
'
;
config
.
plugins
.
push
(
...
...
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