pub serveSend feedback
Serve is one of the commands of the pub tool. Learn more about pub.
$ pub serve [<options>] [<directories>]
This command starts up a development server, or dev server, for your Dart web app. The dev server is an HTTP server on localhost that serves up your web app’s assets.
Start the dev server from the directory that contains your web app’s
$ cd ~/dart/helloworld $ pub serve Serving helloworld on http://localhost:8080
These output assets aren’t in the file system; they exist only in the dev
server. When you’re ready to deploy, generate output files by running
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.
For options that apply to all pub commands, see Global options.
- Optional. Use this option to specify the directories to use
as input for the serve command, in addition to
lib(which is always processed). The default values are
test. Directories you might typically specify include the following:
pub serve test benchmark example/foo barIn the preceding example, the
bardirectories are processed, as is the
webdirectory is not served because it isn't specified.
- Optional. Serves all of the buildable directories (benchmark, bin, example, test, and web) that are present.
- Optional. By default, the dev server listens on
localhost. You can specify another host using the
--hostnameoption. For example:
$ pub serve --hostname=127.0.0.1 Loading source assets... Loading markdown_converter transformers... (1.3s) Serving markdown_converter web on http://127.0.0.1:8080 Build completed successfully
- Optional. By default, the dev server uses
http://localhost:8080. To change the port number, use the
$ pub serve --port=9080 Serving helloworld web on http://localhost:9080
- 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 "debug".
- Optional (added in 1.24).
Possible values are "dart2js",
If this option is omitted, its default value is "dart2js".