Build is one of the commands of the pub tool. Learn more about pub.
$ pub build [<options>] [<directories>] [--output=<directory>]
pub build when you’re ready to deploy your web app.
When you run
pub build, it generates the
for the current package and all of its dependencies, putting them into
new directory named
pub build, just run it in your package’s root directory. For example:
$ cd ~/dart/helloworld $ pub build Building helloworld...... Built 5 files!
If the build directory already exists,
pub build deletes it and then creates
To generate assets,
pub build uses
Any source assets that aren’t transformed are copied,
as is, into the build directory or one of its subdirectories.
Pub also automatically compiles your
(or the specified compiler).
See Configuring the Built-in dart2js Transformer
for information on how to configure the dart2js options in your pubspec.
See Pub Assets and Transformers for information on:
- Where in your package to put assets.
- What URLs to use when referring to assets.
- How to use
pubspec.yamlto specify which transformers run, and in what order.
pub serve. With
pub serve, you can run a
development server that continuously generates and serves assets.
For options that apply to all pub commands, see Global options.
- Optional. Use this option to specify directories to use
as input for the build command, in addition to
lib(which is always processed). The default value is
web. Directories you might typically specify include the following:
pub build test benchmark example/foo barIn the preceding example, the
bardirectories are processed, as is the
webdirectory is not built because it isn't specified.
- Optional. Builds all of the buildable directories (benchmark, bin, example, test, and web) that are present.
- Optional. Specifies a transformation mode. Typical values are "debug"
and "release", but any word is allowed.
Transformers may use this to change how they behave.
.dartfiles in the build output. In any other mode, the raw Dart files are included.
If this option is omitted, its default value is "release".
- Optional. Specifies where to put the build output. The default is the
- Optional (added in 1.24).
Possible values are "dart2js",
If this option is omitted, its default value is "dart2js".