| OLD | NEW |
| (Empty) |
| 1 --- | |
| 2 title: "Command: Serve" | |
| 3 --- | |
| 4 | |
| 5 $ pub serve [--port <number>] | |
| 6 | |
| 7 This command starts up a _development server_, or _dev server_, | |
| 8 for your Dart web app. The dev server is an HTTP server on localhost | |
| 9 that serves up your web app's [assets](glossary.html#asset). | |
| 10 | |
| 11 Start the dev server from the directory that contains your web app's | |
| 12 `pubspec.yaml` file: | |
| 13 | |
| 14 $ cd ~/dart/helloworld | |
| 15 $ pub serve | |
| 16 Serving helloworld on http://localhost:8080 | |
| 17 | |
| 18 The dev server doesn't just serve up assets, it produces them by running | |
| 19 [transformers](glossary.html#transformer). A transformer converts input | |
| 20 assets (such as Dart files or Polymer-formatted HTML) into output assets | |
| 21 (such as JavaScript and HTML). | |
| 22 | |
| 23 These output assets aren't in the file system; they exist only in the dev | |
| 24 server. When you're ready to deploy, generate output files by running | |
| 25 [`pub build`](pub-build.html). | |
| 26 | |
| 27 Pub automatically includes a dart2js transformer that compiles your Dart code | |
| 28 to JavaScript. With this, you can change some Dart code, refresh your | |
| 29 non-Dartium browser, and immediately see the changes. | |
| 30 | |
| 31 See [Assets and Transformers](assets-and-transformers.html) for | |
| 32 information on: | |
| 33 | |
| 34 * Where in your package to put assets. | |
| 35 * What URLs to use when referring to assets. | |
| 36 * How to use `pubspec.yaml` to specify which transformers run, and in | |
| 37 what order. | |
| 38 | |
| 39 ## Options | |
| 40 | |
| 41 ### `--port` | |
| 42 | |
| 43 By default the dev server uses `http://localhost:8080`. To change the port | |
| 44 number, use the `--port` option: | |
| 45 | |
| 46 $ pub serve --port 9080 | |
| 47 Serving helloworld on http://localhost:9080 | |
| 48 | |
| 49 ### `--mode=<mode>` | |
| 50 | |
| 51 Specifies a transformation mode. Typical values are "debug" and "release", but | |
| 52 any word is allowed. Transformers may use this to change how they behave. | |
| 53 | |
| 54 If set to "release" pub will generate minified JavaScript using dart2js. | |
| 55 Otherwise, it generates it unminified. Also, in release mode, Pub will not | |
| 56 include any source .dart files in the resulting build output since they have | |
| 57 been compiled to JavaScript. In any other mode, the raw Dart files will be | |
| 58 included. | |
| 59 | |
| 60 If omitted, it defaults to "debug". | |
| 61 | |
| 62 ## What about Dart Editor's server? | |
| 63 | |
| 64 Dart Editor has its own dev server. We plan to unify it with the | |
| 65 pub dev server soon. | |
| OLD | NEW |