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.
Globally install webdev using pub:
$ pub global activate webdev
To launch a development server, which serves your app and watches for source code changes, use the following command:
webdev serve [--release] [ [<directory>[:<port>]] ... ]
By default your app is compiled using dartdevc and served from the
directory on port
$ webdev serve
To build using dart2js, add the
You can specify different directory-port configurations. For example, the following command sets up an additional port to run component tests in the browser at localhost:8081:
$ webdev serve web test:8081
To run tests directly from the command line use build_runner test.
Use the following command to build your app:
webdev build [--no-release] --output [<dirname>:]<dirname>
The first build is the slowest. After that, assets are cached on disk and incremental builds are much faster.
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.