-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Print webpack console to browser console #1063
Merged
Merged
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f6f958c
copied status.js from overlay.js
Wernerson 7c77b5c
first version
Wernerson d74e667
added example
Wernerson 4223363
added checkif status is set
Wernerson 4721cfa
changed description
Wernerson eca5338
fixed config schema
Wernerson 4ca0a82
fixed validation testcase
Wernerson 095332e
added status to title
Wernerson 70db8dd
changed status div style
Wernerson 6bb4fd8
added status window delay
Wernerson 6d72910
made status work better with overlay
Wernerson 68fb260
added status bar
Wernerson a31f46c
added status update
Wernerson a29b0c1
added progress updates on backend
Wernerson a96a5d2
changed progress bar color to webpack logo color
Wernerson e7c29d4
added second webpack logo color as comment
Wernerson 34c840d
merged with local changes
Wernerson 94502a0
added compilation status to title
Wernerson d98bbc0
ran prepublish, posttest and beautify
Wernerson bd64321
fixed codacy issues
Wernerson dccf845
fixed codacy issues
Wernerson 9716cf9
Merge branch 'master' into feat/compile-popup
Wernerson c64be22
fixed merge error
Wernerson 5fc1b51
console-progress v1
Wernerson 44e8c72
Merge branch 'feat/console-progress'
Wernerson 4219340
Merge remote-tracking branch 'webpack-dev-server/master' into feat/co…
Wernerson 131b6da
Merge branch 'master' of https://github.com/webpack/webpack-dev-server
Wernerson 8c8c229
fixed little bugs
Wernerson 27cb246
fixed lint errrors (LF -> CRLF)
Wernerson 6cb0f62
Merge branch 'master' into feat/console-progress
Wernerson 068559b
Merge branch 'master' into feat/console-progress
Wernerson 2c68d7a
Merge branch 'master' into feat/console-progress
Wernerson 1978919
load plugin only if progress is enabled
Wernerson aab052d
linted Server.js
Wernerson a0fc7ad
Merge branch 'master' into feat/console-progress
Wernerson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Status | ||
|
||
```shell | ||
node ../../bin/webpack-dev-server.js --open | ||
``` | ||
|
||
## What should happen | ||
|
||
The script should open the browser and show a heading with "Example: progress". | ||
|
||
In `app.js`, change the text and save. You should see the compilation progress in the browser console. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
// Change the following line and save to see the compilation status | ||
|
||
document.write('Change me to see compilation progress in console...'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Progress example</title> | ||
<script src="/bundle.js" type="text/javascript" charset="utf-8"></script> | ||
</head> | ||
<body> | ||
<h1>Example: progress</h1> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
context: __dirname, | ||
entry: './app.js', | ||
devServer: { | ||
progress: true | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ function Server(compiler, options) { | |
this.headers = options.headers; | ||
this.clientLogLevel = options.clientLogLevel; | ||
this.clientOverlay = options.overlay; | ||
this.progress = options.progress; | ||
this.disableHostCheck = !!options.disableHostCheck; | ||
this.publicHost = options.public; | ||
this.allowedHosts = options.allowedHosts; | ||
|
@@ -52,8 +53,15 @@ function Server(compiler, options) { | |
const invalidPlugin = () => { | ||
this.sockWrite(this.sockets, 'invalid'); | ||
}; | ||
const progressPlugin = new webpack.ProgressPlugin((percent, msg, addInfo) => { | ||
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. should probably only load this plugin if |
||
percent = Math.floor(percent * 100); | ||
if (percent === 100) msg = 'Compilation competed'; | ||
if (addInfo) msg = `${msg} (${addInfo})`; | ||
this.sockWrite(this.sockets, 'progress-update', { percent, msg }); | ||
}); | ||
compiler.plugin('compile', invalidPlugin); | ||
compiler.plugin('invalid', invalidPlugin); | ||
compiler.apply(progressPlugin); | ||
compiler.plugin('done', (stats) => { | ||
this._sendStats(this.sockets, stats.toJson(clientStats)); | ||
this._stats = stats; | ||
|
@@ -518,6 +526,8 @@ Server.prototype.listen = function (port, hostname, fn) { | |
|
||
if (this.clientLogLevel) { this.sockWrite([conn], 'log-level', this.clientLogLevel); } | ||
|
||
if (this.progress) { this.sockWrite([conn], 'progress', this.progress); } | ||
|
||
if (this.clientOverlay) { this.sockWrite([conn], 'overlay', this.clientOverlay); } | ||
|
||
if (this.hot) this.sockWrite([conn], 'hot'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,14 @@ | |
} | ||
] | ||
}, | ||
"progress": { | ||
"description": "Shows compilation progress in browser console.", | ||
"anyOf": [ | ||
{ | ||
"type": "boolean" | ||
} | ||
] | ||
}, | ||
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. "progress": {
"description": "Shows compilation progress in browser console.",
"type": "boolean"
}, |
||
"key": { | ||
"description": "The contents of a SSL key.", | ||
"anyOf": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Isn't this super spammy?
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.
given that it's an opt-in and the browser console doesn't have control characters, I don't believe it is.