Serve is one of the commands of the pub tool. Learn more about pub.
$ pub serve [--hostname=<host>] [--port=<number>] [--mode=<mode>] [<directories>] $ pub serve [--hostname=<host>] [--port=<number>] [--mode=<mode>] [--all]
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 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:
pubspec.yamlto specify which transformers run, and in what order.
For options that apply to all pub commands, see Global options.
lib(which is always processed). The default values are
test. Directories you might specify typically 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.
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
http://localhost:8080. To change the port number, use the
$ pub serve --port=9080 Serving helloworld web on http://localhost:9080