-
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
Conversation
|
||
## Environment Setup | ||
### Install a web server | ||
Because you will not be using webpack-dev-server 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 [live-server](https://www.npmjs.com/package/live-server) as it will auto-reload your browser when new files are outputed. |
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.
Shoudln't this be https://github.com/johnpapa/lite-server instead? Otherwise it won't have fallback.
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.
good point. i agree
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.
outputed --> output
@@ -20,3 +20,4 @@ | |||
- [Routing](stories/routing) | |||
- [3rd Party Lib](stories/third-party-lib) | |||
- [Corporate Proxy](stories/using-corporate-proxy) | |||
- [Serve from Disk](stories/disk-serve) |
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.
@@ -0,0 +1,23 @@ | |||
# Serving from Disk | |||
|
|||
The CLI supports running a live 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). |
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.
live reload --> live browser reload
|
||
The CLI supports running a live 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. |
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.
My motivation for this is to verify that what will be in the /dist
folder , which is also what I may send to a production server later, is indeed ok when served. This is important for folks who want to be super careful. I personally dont trust "well, it ran in memory, so it will certainly run off disk" ... why? because maybe somewhere in the black box there is something different.
Point here is that I think we should add something mentioning this motivation. And that it is easy to do your own verification following your forthcoming steps.
|
||
## Environment Setup | ||
### Install a web server | ||
Because you will not be using webpack-dev-server 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 [live-server](https://www.npmjs.com/package/live-server) as it will auto-reload your browser when new files are outputed. |
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.
"Because you will not be using webpack-dev-server you will need" --> "You will not be using webpack-dev-server , so you will need"
dont end or start sentence with preposition, when it can be avoided.
|
||
## Environment Setup | ||
### Install a web server | ||
Because you will not be using webpack-dev-server 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 [live-server](https://www.npmjs.com/package/live-server) as it will auto-reload your browser when new files are outputed. |
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.
good point. i agree
|
||
## Environment Setup | ||
### Install a web server | ||
Because you will not be using webpack-dev-server 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 [live-server](https://www.npmjs.com/package/live-server) as it will auto-reload your browser when new files are outputed. |
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.
outputed --> output
Because you will not be using webpack-dev-server 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 [live-server](https://www.npmjs.com/package/live-server) as it will auto-reload your browser when new files are outputed. | ||
|
||
## Usage | ||
In order to mimic the live-reload you get with `ng serve` by default you will need to open two terminals. 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`. |
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.
suggest ...
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 thedist
folder. The combination of these two processes will mimic the same behavior ofng serve
.
``` | ||
### 2nd terminal - Start the web server | ||
```bash | ||
live-server dist |
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.
lite-server
``` | ||
|
||
### Open browser | ||
Navigate to the URL the web server uses. (The default URL for live-server is `http://127.0.0.1:8080`) |
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.
lite-server opens the browser by default, too
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.
lite-server --baseDir="dist"
with 2.3.0
@johnpapa & @filipesilva this has been updated with the suggestions |
|
||
## 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 comment
The reason will be displayed to describe this comment to others. Learn more.
should we tell them how to install it?
npm i lite-server
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.
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?
if locally installed, update npm scripts?
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.
I think a user wanting to do this would understand that its not part of the CLI. The furthest I would go is npm - lite-server --save-dev
and add an npm script or npm i lite-server -g
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Closes #4290