Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

Brocco
Copy link
Contributor

@Brocco Brocco commented Mar 8, 2017

Closes #4290


## 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.
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. i agree

Copy link
Contributor

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)
Copy link
Contributor

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).
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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`.
Copy link
Contributor

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 the dist folder. The combination of these two processes will mimic the same behavior of ng serve.

```
### 2nd terminal - Start the web server
```bash
live-server dist
Copy link
Contributor

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`)
Copy link
Contributor

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

Copy link
Contributor

@johnpapa johnpapa Mar 8, 2017

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

@Brocco Brocco force-pushed the disk-serve-docs branch from bcbd37c to 832eca5 Compare March 8, 2017 21:25
@Brocco
Copy link
Contributor Author

Brocco commented Mar 8, 2017

@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.
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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 :)

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

@Brocco Brocco deleted the disk-serve-docs branch March 15, 2017 17:47
asnowwolf pushed a commit to asnowwolf/angular-cli that referenced this pull request Apr 12, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs Feature Request: Serving from /dist
4 participants