livereload 0.4.0

  • Installing
  • Versions
  • new50



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. uses Dart 1.x SDK to generate docs and fails to build, so I need to build the docs myself.


This package runs pub run build_runner serve under the hood. So, package: build_runner needs to be installed along with this package.

Edit your pubspec.yaml

  build_runner: ^0.7.9
  build_web_compilers: ^0.3.0
  livereload: ^0.4.0

and run

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">

  <!-- <base> is needed. -->
  <base href="/">
  <script defer src="main.dart.js"></script>

  <!-- AngularDart with angular_router -->


Command Line Options

Most of the options replicate those of package: build_runner. You can config your build through build.yaml, the same way as you would do with package: build_runner.

pub run livereload [directory] [options]
  • If the directory is omitted, web will be served.
  • -l, --low-resources-mode: Reduces the amount of memory consumed by the build process.
  • -c, --config: Reads build.<name>.yaml instead of the default build.yaml.
  • --define: Sets the global options config for a builder by key. As an example, enabling the dart2js compiler would look like: --define "build_web_compilers|entrypoint=compiler=dart2js"
  • --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_runner serves. (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 is a shelf proxy server, so you can write your own .dart file which imports this library (docs) and add more middlewares to your heart's content.



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 --proxyport to --port, which should be less confusing.
  • Change the behavior of the default shouldBeRewritten to rewrite any request which doesn't have a MIME type with 404 response to /.
  • buildRunnerServe function is removed. Use BuildRunnerServeProcess instead.
  • startWebSocketServer function is removed. Use WebSocketServer instead.
  • startLiveReloadWebSocketServer function is removed. Use LiveReloadWebSocketServer instead.
  • startProxyServer function is removed. Use ProxyServer and LiveReloadProxyServer instead.

Bug Fixes

  • Properly kill the build_runner serve process and force the proxy server and the WebSocket server to close, closes [#5].


  • rewriteAs is now deprecated. Use the newly added rewriteTo.
  • startLiveReloadProxyServer is now deprecated. Use the now exposed liveReloadPipeline and liveReloadSpaPipeline with startProxyServer instead.
  • injectJavaScript now automatically adds <script></script>.


  • Improved the documentation.


  • A script listening for reload signals is now automatically injected. client.dart is not necessary anymore.
  • Some command line options have changed, e.g. directory:port => directory --buildport=port.


  • Adds docs.


  • Initial version.

1. Depend on it

Add this to your package's pubspec.yaml file:

  livereload: "^0.4.0"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:livereload/livereload.dart';
Version Uploaded Documentation Archive
0.4.0 Feb 21, 2018 Go to the documentation of livereload 0.4.0 Download livereload 0.4.0 archive
0.3.0 Feb 13, 2018 Go to the documentation of livereload 0.3.0 Download livereload 0.3.0 archive
0.2.0+1 Feb 13, 2018 Go to the documentation of livereload 0.2.0+1 Download livereload 0.2.0+1 archive
0.2.0 Feb 12, 2018 Go to the documentation of livereload 0.2.0 Download livereload 0.2.0 archive
0.1.0+1 Feb 11, 2018 Go to the documentation of livereload 0.1.0+1 Download livereload 0.1.0+1 archive
0.1.0 Feb 10, 2018 Go to the documentation of livereload 0.1.0 Download livereload 0.1.0 archive


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 21, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: Flutter, other

Primary library: package:livereload/livereload.dart with components: io.


  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use livereload.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <2.0.0
args ^1.3.0 1.3.0
io ^0.3.0 0.3.2+1
logging ^0.11.0 0.11.3+1
mime ^0.9.0 0.9.6
path ^1.5.0 1.5.1
shelf ^0.7.0 0.7.2
shelf_proxy ^0.1.0 0.1.0+4
shelf_web_socket ^0.2.0 0.2.2
web_socket_channel ^1.0.0 1.0.6 1.0.7
Transitive dependencies
async 2.0.3 2.0.4
charcode 1.1.1
collection 1.14.5
convert 2.0.1
crypto 2.0.2+1
http 0.11.3+16
http_parser 3.1.1
meta 1.1.2
source_span 1.4.0
stack_trace 1.9.2
stream_channel 1.6.3
string_scanner 1.0.2
typed_data 1.1.5