The webdev package provides a command line interface (CLI) for users and
tools to build and serve web apps.
webdev tool is built on build_runner and replaces
pub build and
serve. If you’ve previously used
build_runner, you should no longer need to
use it directly, except to run tests from the command line.
Installing and updating webdev
Globally install webdev using pub:
$ pub global activate webdev
Use the same command to update webdev.
We recommend updating webdev whenever you update your Dart SDK
webdev commands unexpectedly fail.
To launch a development server, which serves your app and watches for source code changes, use the following command:
webdev serve [--release] [ [<directory>[:<port>]] ... ]
$ webdev serve # uses dartdevc
The first dartdevc build is the slowest. After that, assets are cached on disk, and incremental builds are much faster.
To use dart2js instead of dartdevc, add the
$ webdev serve --release # uses dart2js
You can specify different directory-port configurations. For example, the following command changes the test port from the default (8081) to 8083:
$ webdev serve web test:8083 # App: 8080; tests: 8083
To run tests directly from the command line,
webdev use build_runner test.
Use the following command to build your app:
webdev build [--no-release] --output [<dirname>:]<dirname>
By default, the
build command uses the dart2js web compiler to create a
production version of your app. Add
--no-release to compile with dartdevc.
--output option, you can control which top-level project folders are
compiled and where output is written.
For example, the following command uses the dartdevc to compile the project’s
web folder into the
$ webdev build --no-release --output web:build
You can customize your build using build config files. For more information, see Build config files.
For a complete list of
webdev options, run
webdev --help or see the
webdev package README.