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