Skip to content

Add flag to prevent "dist" folder from being deleted during ng build #5925

Closed
@DanWahlin

Description

@DanWahlin

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

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenteffort1: easy (hours)freq1: lowOnly reported by a handful of users who observe it rarelyseverity2: inconvenient

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions