-
Notifications
You must be signed in to change notification settings - Fork 215
Restore --live-reload option #1778
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
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ import 'package:path/path.dart' as p; | |
const assumeTtyOption = 'assume-tty'; | ||
const defineOption = 'define'; | ||
const deleteFilesByDefaultOption = 'delete-conflicting-outputs'; | ||
const liveReloadOption = 'live-reload'; | ||
const hotReloadOption = 'hot-reload'; | ||
const logPerformanceOption = 'log-performance'; | ||
const logRequestsOption = 'log-requests'; | ||
|
@@ -131,12 +132,14 @@ class SharedOptions { | |
/// Options specific to the `serve` command. | ||
class ServeOptions extends SharedOptions { | ||
final String hostName; | ||
final bool liveReload; | ||
final bool hotReload; | ||
final bool logRequests; | ||
final List<ServeTarget> serveTargets; | ||
|
||
ServeOptions._({ | ||
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. We should add some validation here that both |
||
@required this.hostName, | ||
@required this.liveReload, | ||
@required this.hotReload, | ||
@required this.logRequests, | ||
@required this.serveTargets, | ||
|
@@ -203,6 +206,7 @@ class ServeOptions extends SharedOptions { | |
|
||
return ServeOptions._( | ||
hostName: argResults[hostnameOption] as String, | ||
liveReload: argResults[liveReloadOption] as bool, | ||
hotReload: argResults[hotReloadOption] as bool, | ||
logRequests: argResults[logRequestsOption] as bool, | ||
serveTargets: serveTargets, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,14 @@ class ServeCommand extends WatchCommand { | |
defaultsTo: false, | ||
negatable: false, | ||
help: 'Enables logging for each request to the server.') | ||
..addFlag(liveReloadOption, | ||
defaultsTo: false, | ||
negatable: false, | ||
help: 'Enables automatic page reloading on rebuilds.') | ||
..addFlag(hotReloadOption, | ||
defaultsTo: false, | ||
negatable: false, | ||
help: 'Enables automatic page reloading on rebuilds.'); | ||
help: 'Enables automatic reloading of changed modules.'); | ||
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. nit: ... on rebuilds. |
||
} | ||
|
||
@override | ||
|
@@ -90,7 +94,9 @@ class ServeCommand extends WatchCommand { | |
serveRequests( | ||
server, | ||
handler.handlerFor(target.dir, | ||
logRequests: options.logRequests, hotReload: options.hotReload)); | ||
logRequests: options.logRequests, | ||
liveReload: options.liveReload, | ||
hotReload: options.hotReload)); | ||
}); | ||
|
||
_ensureBuildWebCompilersDependency(packageGraph, logger); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var _buildUpdatesProtocol = '$buildUpdates'; | ||
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. nit, wrap this all in an anonymous function (function() {
...
})() |
||
|
||
var ws = new WebSocket('ws://' + location.host, [_buildUpdatesProtocol]); | ||
ws.onmessage = function (event) { | ||
location.reload(); | ||
}; |
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.
If you provide both which one takes precedence? Could potentially model this as an enum to prevent that issue.