livereload 0.4.1

  • Readme
  • Changelog
  • Installing
  • 1

livereload #


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.

Installation #

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.13
  build_web_compilers: ^0.3.0
  livereload: ^0.4.0

and run

pub get --no-precompile

Usage #

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.

Changelog #

0.4.1 #

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.

0.4.0 #

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.

Features #

  • 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.

0.3.0 #

  • 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>.

0.2.0+1 #

  • Improved the documentation.

0.2.0 #

  • 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.

0.1.0+1 #

  • Adds docs.

0.1.0 #

  • Initial version.

Use this package as a library

1. Depend on it

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

  livereload: ^0.4.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub 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';
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]
Learn more about scoring.

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 pubspec.yaml.

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

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <2.0.0