-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
add liveReload option to enable/disable refreshing the page #1812
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1812 +/- ##
==========================================
- Coverage 88.34% 88.26% -0.08%
==========================================
Files 14 14
Lines 815 818 +3
Branches 258 260 +2
==========================================
+ Hits 720 722 +2
- Misses 82 83 +1
Partials 13 13
Continue to review full report at Codecov.
|
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.
Need tests, thanks for PR, looks good
@evilebottnawi I couldn't find any way to test the actual code except using the browser and testing it manually, so I had to create a simple simulation it does exactly like what the actual code does. if you have any idea or examples to write a test to check if the page reloads or not it'll be very helpful to write a better test. |
@evilebottnawi AppVeyor has a connection problem |
@EladBezalel We dropped travis and appveyor. Could you rebase? |
4d7afe0
to
0285f1d
Compare
@hiroppy I did a mistake in rebasing, can you please tell me the right way to rebase? and is everything ok or should I fix something? |
The rebasing seems to be successful. However, CI fails.
Please update test/options.test.js |
lib/options.json
Outdated
@@ -4,6 +4,15 @@ | |||
"after": { | |||
"instanceof": "Function" | |||
}, | |||
"serveIndex": { |
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.
Please delete here(master has already had serverIndex)
/~https://github.com/webpack/webpack-dev-server/blob/master/lib/options.json#L282
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.
Done :)
lib/options.json
Outdated
"liveReload": { | ||
"type": "boolean" | ||
}, | ||
"hot": { |
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.
Please delete here(master has already had hot)
/~https://github.com/webpack/webpack-dev-server/blob/master/lib/options.json#L113
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.
Done :)
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.
Good job, small fixes
lib/Server.js
Outdated
this.headers = this.options.headers; | ||
this.progress = this.options.progress; | ||
this.hot = options.hot || options.hotOnly; | ||
this.liveReload = options.liveReload; |
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.
Don't use this.liveReload
(this variables will be removed in next major release), please use this.options.liveReload
in code
lib/Server.js
Outdated
@@ -790,6 +791,10 @@ class Server { | |||
this.sockWrite([connection], 'progress', this.progress); | |||
} | |||
|
|||
if (this.liveReload !== false) { |
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.
this.options.liveReload
lib/Server.js
Outdated
this.sockWrite(this.sockets, 'content-changed'); | ||
}); | ||
// disabling refreshing on changing the content | ||
if (this.liveReload !== false) { |
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.
this.options.liveReload
lib/Server.js
Outdated
@@ -95,7 +95,7 @@ class Server { | |||
|
|||
// TODO this.<property> is deprecated (remove them in next major release.) in favor this.options.<property> | |||
this.hot = options.hot || options.hotOnly; | |||
this.liveReload = options.liveReload; | |||
this.options.liveReload = options.liveReload; |
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.
No need this line after refactor, we already have this.options.liveReload
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.
One note
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.
Good, let's wait CI green
@evilebottnawi coverage tests didn't pass so I did a small fix maybe using |
@evilebottnawi anything i can modify or fix to pass the tests ? |
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.
Need add test for /~https://github.com/webpack/webpack-dev-server/blob/master/test/CreateConfig.test.js, becase use should support --no-live-reload
using CLI (no need tests for CLI)
@@ -88,6 +88,10 @@ function createConfig(config, argv, { port }) { | |||
options.hotOnly = argv.hotOnly; | |||
} | |||
|
|||
if (!options.liveReload) { | |||
options.liveReload = argv.liveReload; | |||
} |
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.
webpack-dev-server/lib/utils/createConfig.js
Line 114 in 9a86d02
else if (argv.contentBase === false) { |
--no-live-reload
because be default liveReload
should be true
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.
One note
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.
Looks good, due we don't have CLI tests, can you manually testing?
@evilebottnawi I tested it and it's working with me. |
Awesome thanks! |
@evilebottnawi what went wrong? I think I missed to add a test to test |
@EslamHiko Awesome === Great/Good |
Need update snapshot to fix CI problem |
@evilebottnawi I updated my snapshot. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
46b1f70
to
cadee8b
Compare
@EslamHiko I did the following things
thanks |
yay, CI is green 🍏 |
@hiroppy 🎉 🎉 i hope everything is fine now 😄 |
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.
/cc @hiroppy approve?
/cc @EslamHiko need rebase again, sorry |
5245bcc
to
92cddd7
Compare
Close in favor #1889 |
For Bugs and Features; did you add new tests?
I'm not sure how i would test this feature except using the browser
Motivation / Use-Case
fixes #1744
Breaking Changes
No
Additional Info
live reloading is enabled by default