New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: #1719 #2017
base: master
Are you sure you want to change the base?
fix: #1719 #2017
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ $(() => { | |
} | ||
}, | ||
ok() { | ||
console.log('OK!!'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why you need |
||
okness.text(''); | ||
$errors.hide(); | ||
reloadApp(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,17 +171,17 @@ class Server { | |
|
||
setupHooks() { | ||
// Listening for events | ||
const invalidPlugin = () => { | ||
this.sockWrite(this.sockets, 'invalid'); | ||
const invalidPlugin = (compilerName) => { | ||
this.sockWrite(this.sockets, 'invalid', compilerName); | ||
}; | ||
|
||
const addHooks = (compiler) => { | ||
const { compile, invalid, done } = compiler.hooks; | ||
|
||
compile.tap('webpack-dev-server', invalidPlugin); | ||
invalid.tap('webpack-dev-server', invalidPlugin); | ||
compile.tap('webpack-dev-server', invalidPlugin.bind(this, compiler.options.name)); | ||
invalid.tap('webpack-dev-server', invalidPlugin.bind(this, compiler.options.name)); | ||
done.tap('webpack-dev-server', (stats) => { | ||
this._sendStats(this.sockets, this.getStats(stats)); | ||
this._sendStats(compiler, this.sockets, this.getStats(stats)); | ||
this._stats = stats; | ||
}); | ||
}; | ||
|
@@ -719,7 +719,7 @@ class Server { | |
return; | ||
} | ||
|
||
this._sendStats([connection], this.getStats(this._stats), true); | ||
this._sendStats(null, [connection], this.getStats(this._stats), true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. null? |
||
}); | ||
} | ||
|
||
|
@@ -938,7 +938,7 @@ class Server { | |
} | ||
|
||
// send stats to a socket or multiple sockets | ||
_sendStats(sockets, stats, force) { | ||
_sendStats(compiler, sockets, stats, force) { | ||
if ( | ||
!force && | ||
stats && | ||
|
@@ -956,7 +956,7 @@ class Server { | |
} else if (stats.warnings.length > 0) { | ||
this.sockWrite(sockets, 'warnings', stats.warnings); | ||
} else { | ||
this.sockWrite(sockets, 'ok'); | ||
this.sockWrite(sockets, 'ok', compiler && compiler.options.name); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,13 @@ | |
const webpack = require('webpack'); | ||
const addEntries = require('./addEntries'); | ||
|
||
function guid() { | ||
function s4() { | ||
return ((1 + Math.random()) * 0x10000 | 0).toString(16).substring(1); | ||
} | ||
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better use package for this |
||
|
||
function updateCompiler(compiler, options) { | ||
if (options.inline !== false) { | ||
const findHMRPlugin = (config) => { | ||
|
@@ -21,18 +28,21 @@ function updateCompiler(compiler, options) { | |
|
||
const compilers = []; | ||
const compilersWithoutHMR = []; | ||
let webpackConfig; | ||
let webpackConfigs = []; | ||
if (compiler.compilers) { | ||
webpackConfig = []; | ||
compiler.compilers.forEach((compiler) => { | ||
webpackConfig.push(compiler.options); | ||
webpackConfigs.push(compiler.options); | ||
let name = compiler.options.name || guid(); | ||
compiler.options.name = name; | ||
compilers.push(compiler); | ||
if (!findHMRPlugin(compiler.options)) { | ||
compilersWithoutHMR.push(compiler); | ||
} | ||
}); | ||
} else { | ||
webpackConfig = compiler.options; | ||
webpackConfigs = [compiler.options]; | ||
let name = compiler.options.name || guid(); | ||
compiler.options.name = name; | ||
compilers.push(compiler); | ||
if (!findHMRPlugin(compiler.options)) { | ||
compilersWithoutHMR.push(compiler); | ||
|
@@ -44,7 +54,11 @@ function updateCompiler(compiler, options) { | |
// the changes we are making to the compiler | ||
// important: this relies on the fact that addEntries now | ||
// prevents duplicate new entries. | ||
addEntries(webpackConfig, options); | ||
for (let i = 0; i < compilers.length; i ++) { | ||
const compiler = compilers[i]; | ||
const config = webpackConfigs[i]; | ||
addEntries(compiler, config, options); | ||
} | ||
compilers.forEach((compiler) => { | ||
const config = compiler.options; | ||
compiler.hooks.entryOption.call(config.context, config.entry); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to
util