-
Notifications
You must be signed in to change notification settings - Fork 12k
docs(@angular/cli): document serving the app from disk #5308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Serve from Disk | ||
|
||
The CLI supports running a live browser reload experience to users by running `ng serve`. This will compile the application upon file saves and reload the browser with the newly compiled application. This is done by hosting the application in memory and serving it via [webpack-dev-server](https://webpack.js.org/guides/development/#webpack-dev-server). | ||
|
||
If you wish to get a similar experience with the application output to disk please use the steps below. This practice will allow you to ensure that serving the contents of your `dist` dir will be closer to how your application will behave when it is deployed. | ||
|
||
## Environment Setup | ||
### Install a web server | ||
You will not be using webpack-dev-server, so you will need to install a web server for the browser to request the application. There are many to choose from but a good one to try is [lite-server](https://github.com/johnpapa/lite-server) as it will auto-reload your browser when new files are output. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we tell them how to install it?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a link to the repo and it's in that readme, so I'm a little torn on this one, but it doesn't hurt to add, but then we get into... install globally? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a user wanting to do this would understand that its not part of the CLI. The furthest I would go is because if they install it locally, they need the script. or we skip it all. im fine with that too :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we skip it, because it avoids people's concerns over using yarn instead. I think that if people are concerned enough to want to serve from disk that they can handle installing a web server that is linked to. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed |
||
|
||
## Usage | ||
You will need two terminals to get the live-reload experience. The first will run the build in a watch mode to compile the application to the `dist` folder. The second will run the web server against the `dist` folder. The combination of these two processes will mimic the same behavior of ng serve. | ||
|
||
### 1st terminal - Start the build | ||
```bash | ||
ng build --watch | ||
``` | ||
|
||
### 2nd terminal - Start the web server | ||
```bash | ||
lite-server --baseDir="dist" | ||
``` | ||
When using `lite-server` the default browser will open to the appropriate URL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, but you say "serve from disk" here and later it is "serving from disk" I'd pick and be consistent.