A simple Dart development server that serves a web app, automatically refreshes on changes, and is compatible with single page apllications (SPA) that utilize the history API.
This package runs
pub run build_runner serve under the hood. So,
package: build_runner needs to be installed along with this package.
dev_dependencies: build_runner: ^0.7.13 build_web_compilers: ^0.3.0 livereload: ^0.4.0
pub get --no-precompile
pub run livereload
Then, browse your web app at http://localhost:8000.
If you are going to build an SPA, make sure to add a proper
<base> so that your routing works.
<!DOCTYPE html> <html lang="en"> <head> <!-- <base> is needed. --> <base href="/"> <script defer src="main.dart.js"></script> <title>SPA</title> </head> <body> <!-- AngularDart with angular_router --> <my-app>Loading...</my-app> </body> </html>
Command Line Options #
pub run livereload [directory] [options]
- If the directory is omitted,
webwill be served.
- -l, --low-resources-mode: Reduces the amount of memory consumed by the build process.
- -c, --config: Reads
build.<name>.yamlinstead of the default
- --define: Sets the global
optionsconfig for a builder by key. As an example, enabling the dart2js compiler would look like:
- --hostname: Specifies the hostname to serve on. (defaults to "localhost")
- --port: Changes the port number of the livereload server. (defaults to "8000")
- --buildport: Changes the port number where
build_runnerserves. (defaults to "8080")
- --websocketport: Changes the port number of the underlying websocket. (defaults to "4242")
- --[no-]spa: Serves a single page application. This allows routes controlled by history API to be working. (defaults to on)
Further Configuration #
This package heavily relies on
build_runner stdout messages.
build_runner 0.7.13 changed some of the messages and broke this package. This release is a minor patch to fix the issue.
In this release, I want to heavily refactor the code and because no one is actually using the library except for its own CLI, a lot of stuff will be removed without properly deprecated.
- Change log messages to be less confusing.
Breaking Changes #
- Change CLI option from
--port, which should be less confusing.
- Change the behavior of the default
shouldBeRewrittento rewrite any request which doesn't have a MIME type with 404 response to
buildRunnerServefunction is removed. Use
startWebSocketServerfunction is removed. Use
startLiveReloadWebSocketServerfunction is removed. Use
startProxyServerfunction is removed. Use
Bug Fixes #
- Properly kill the
build_runner serveprocess and force the proxy server and the WebSocket server to close, closes #5.
rewriteAsis now deprecated. Use the newly added
startLiveReloadProxyServeris now deprecated. Use the now exposed
- Improved the documentation.
- A script listening for reload signals is now automatically injected.
client.dartis not necessary anymore.
- Some command line options have changed, e.g.
- Adds docs.
- Initial version.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies: livereload: ^0.4.1
2. Install it
You can install packages from the command line:
$ pub get
Alternatively, your editor might support
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.
Analysis issues and suggestions
Support Dart 2 in
The SDK constraint in
pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.
Maintenance issues and suggestions
dartdoc successfully runs on your package's source files. (-10 points)
Dependencies were not resolved.
|Dart SDK||>=2.0.0-dev <2.0.0|