Angular-cli: Add flag to prevent "dist" folder from being deleted during ng build

Created on 12 Apr 2017  路  5Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x ] feature request

Versions.

@angular/cli: 1.0.0
node: 6.10.2
Same result as below for Windows or OSX

Repro steps.

I'm hooking up a Docker nginx container to the "dist" folder through a volume with the following command. Note that $(pwd) would represent the dist folder in this case (the working folder):

docker run -d -p 8080:80 -v $(pwd):/usr/share/nginx/html nginx:alpine

Hitting http://localhost:8080 works fine and the CLI sample app code/bundles in the dist folder work fine and are displayed in the browser.

However, if I run ng build again the dist folder seems to be deleted which then breaks the Docker container volume (since the original host folder that the container volume pointed to is now changed) and nginx will give a 404. I've sh'd into the nginx container and verified that the "html" folder isn't found (which means the "dist" folder isn't found probably due to the volume link breaking - that's what I suspect anyway). For devs wanting to work with "real" servers (nginx, Apache, HAproxy, etc.) to do updates to the CLI generated source code via Docker containers and volumes this presents a challenge.

The log given by the failure.

No failure in the CLI. The failure occurs with the Docker volume created between the nginx container and the dist folder on the host machine. Deleting the dist folder seems to be breaking the docker container volume link.

Desired functionality.

It would be nice to either leave the dist folder there and only delete the contents when performing a new "ng build" or to provide a flag that would allow us to leave the dist folder there for this type of scenario.

Mention any other details that might be useful.

Repo that runs this scenario plus several other containers can be found at https://github.com/DanWahlin/Angular-Docker-Microservices.

If you perform the steps listed in the readme it should fire up fine the first time. But, if you run an ng build again, the dist folder is deleted which seems to break the Docker volume link and nginx will then give a 404 since the original host folder was removed (at least I think that's why it's breaking).

easy (hours) low 2 (required) inconvenient

Most helpful comment

I didn't get the message that the --delete-output-path flag was added for this scenario....thanks! Appreciate it.

All 5 comments

Could we just have a flag for overwrite dist content and a proxy for live reload?

Wow ~ this ticket is describing exactly what I was going through the other day ! xD

I would second the motion of not deleting the dist and delete only its content or adding a flag to not delete it, and just overwrite since it makes adding volumes directly to it a lot trickier..

+1

I didn't get the message that the --delete-output-path flag was added for this scenario....thanks! Appreciate it.

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._

Was this page helpful?
0 / 5 - 0 ratings