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
fef15133
Commit
fef15133
authored
Feb 27, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
configure webpack to watch for new auto-entries instead of restarting webpack with nodemon
parent
fce6a6a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
7 deletions
+28
-7
config/webpack.config.js
config/webpack.config.js
+27
-6
package.json
package.json
+1
-1
No files found.
config/webpack.config.js
View file @
fef15133
...
...
@@ -21,10 +21,16 @@ var DEV_SERVER_LIVERELOAD = process.env.DEV_SERVER_LIVERELOAD !== 'false';
var
WEBPACK_REPORT
=
process
.
env
.
WEBPACK_REPORT
;
var
NO_COMPRESSION
=
process
.
env
.
NO_COMPRESSION
;
var
autoEntriesCount
=
0
;
var
watchAutoEntries
=
[];
function
generateEntries
()
{
// generate automatic entry points
var
autoEntries
=
{};
var
pageEntries
=
glob
.
sync
(
'
pages/**/index.js
'
,
{
cwd
:
path
.
join
(
ROOT_PATH
,
'
app/assets/javascripts
'
)
});
watchAutoEntries
=
[
path
.
join
(
ROOT_PATH
,
'
app/assets/javascripts/pages/
'
),
];
function
generateAutoEntries
(
path
,
prefix
=
'
.
'
)
{
const
chunkPath
=
path
.
replace
(
/
\/
index
\.
js$/
,
''
);
...
...
@@ -34,14 +40,12 @@ function generateEntries() {
pageEntries
.
forEach
((
path
)
=>
generateAutoEntries
(
path
));
// EE-specific auto entries
const
eePageEntries
=
glob
.
sync
(
'
pages/**/index.js
'
,
{
cwd
:
path
.
join
(
ROOT_PATH
,
'
ee/app/assets/javascripts
'
)
});
eePageEntries
.
forEach
((
path
)
=>
generateAutoEntries
(
path
,
'
ee
'
));
watchAutoEntries
.
concat
(
path
.
join
(
ROOT_PATH
,
'
ee/app/assets/javascripts/pages/
'
));
// 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.`
);
}
autoEntriesCount
=
Object
.
keys
(
autoEntries
).
length
;
const
manualEntries
=
{
balsamiq_viewer
:
'
./blob/balsamiq_viewer.js
'
,
...
...
@@ -378,7 +382,24 @@ if (IS_DEV_SERVER) {
};
config
.
plugins
.
push
(
// watch node_modules for changes if we encounter a missing module compile error
new
WatchMissingNodeModulesPlugin
(
path
.
join
(
ROOT_PATH
,
'
node_modules
'
))
new
WatchMissingNodeModulesPlugin
(
path
.
join
(
ROOT_PATH
,
'
node_modules
'
)),
// watch for changes to our automatic entry point modules
{
apply
(
compiler
)
{
compiler
.
plugin
(
'
emit
'
,
(
compilation
,
callback
)
=>
{
compilation
.
contextDependencies
=
[
...
compilation
.
contextDependencies
,
...
watchAutoEntries
,
];
// report our auto-generated bundle count
console
.
log
(
`
${
autoEntriesCount
}
entries from '/pages' automatically added to webpack output.`
);
callback
();
})
},
},
);
if
(
DEV_SERVER_LIVERELOAD
)
{
config
.
plugins
.
push
(
new
webpack
.
HotModuleReplacementPlugin
());
...
...
package.json
View file @
fef15133
{
"private"
:
true
,
"scripts"
:
{
"dev-server"
:
"nodemon -w 'config/webpack.config.js' -
w 'app/assets/javascripts/dispatcher.js' -w 'app/assets/javascripts/pages/**/index.js' -
-exec 'webpack-dev-server --config config/webpack.config.js'"
,
"dev-server"
:
"nodemon -w 'config/webpack.config.js' --exec 'webpack-dev-server --config config/webpack.config.js'"
,
"eslint"
:
"eslint --max-warnings 0 --ext .js,.vue ."
,
"eslint-fix"
:
"eslint --max-warnings 0 --ext .js,.vue --fix ."
,
"eslint-report"
:
"eslint --max-warnings 0 --ext .js,.vue --format html --output-file ./eslint-report.html ."
,
...
...
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