Skip to content

Feature Request: Stop deleting 'dist' directory on 'ng serve' (SILENTLY) #6375

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
JasonGoemaat opened this issue May 18, 2017 · 7 comments
Closed
Assignees
Labels
effort1: easy (hours) P5 The team acknowledges the request but does not plan to address it, it remains open for discussion severity2: inconvenient

Comments

@JasonGoemaat
Copy link

JasonGoemaat commented May 18, 2017

Bug Report or Feature Request (mark with an x)

- [X] feature request

Versions.

@angular/cli: 1.0.0-rc.1
node: 6.10.2
os: win32 x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.1
@angular/compiler-cli: 2.4.9

Repro steps.

run "ng build" then "ng serve"

Desired functionality.

'ng serve' silently deletes the hard-coded 'dist' directory and should not.

Mention any other details that might be useful.

'ng serve' currently deletes the dist directory contents despite having nothing to do with the 'dist' directory. AND IT DOES THIS SILENTLY. The user might build into a different directory and store important information in the dist directory, which they would lose when calling 'ng serve'. People might use the dist directory for a lot of things. They might WANT to check in their weekly builds, either into the same repository or as a submodule so it can be imported into another project to serve the files. They might have a standard at their company to store things in a dist directory and build into a different directory, then 'ng serve' would delete files it has zero rights to delete.

If this is just done because people mistakenly think that 'ng seve' is serving the contents of the 'dist' directory it is a user education item and should be handled by a message when running 'ng serve' explaining this, not by silently deleting files.

A command line parameter like ng serve --keep-dist would be ok. At the very least there should be a message when running ng serve telling the user that it is deleting the contents of a directory.

@Brocco Brocco added P5 The team acknowledges the request but does not plan to address it, it remains open for discussion severity2: inconvenient effort1: easy (hours) labels May 18, 2017
@JasonGoemaat
Copy link
Author

For our workflow we serve the angular-cli app inside an ASP.NET Core web application. The 'dist' directory is a submodule of our angular-cli project and also of the ASP.NET Core web application (in the wwwroot directory). So when we have a new version of the angular code, we do a build, then commit the changes in the submodule (with a tagged version, etc). Then in our ASP.NET Core application we simply update the submodule.

We initially did this because angular-cli wouldn't build in Azure when pulling our project from source control. If that has changed we might go back to just including the angular project as a submodule directly, but still deploys would take an extra couple minutes to build the cli project.

@filipesilva
Copy link
Contributor

I can tell that you put a lot of thought into writing this issue, but I'm sorry to have to tell you that it's still a dupe of #4366, and what had to be said about this subject has been said there (you even commented there yourself).

If you're keeping important things in your dist/ dir, then you have to change outDir in your .angular-cli.json so that the CLI uses another folder for build artifacts it on build/serve commands. Starting in 1.1.0-rc.0 you also have the --delete-output-path flag, defaulting to true.

@JasonGoemaat
Copy link
Author

JasonGoemaat commented May 18, 2017

@filipesilva Ok, you laid down the law. Despite it not being the best option for some people you still want to delete a directory and have no option to avoid this.

At the very least you should inform the user when they run 'ng serve' that it is deleting a directory. I don't know how you can say it's a good practice to delete a directory without informing a user. A directory they know was created and populated when they ran 'ng build', or maybe a directory they put non-build related files in themselves when they changed the build output to go to another directory. I don't know how any user wouldn't be surprised when those contents were suddenly gone unless they are reading these issues.

The 'ng serve' command has nothing to do with the directory. The 'ng build' command is what populates that directory. Deleting the contents when 'ng serve' is run is a hack because some users mistakenly thought they were getting that directory's contents with 'ng serve', but it isn't well documented and it is counter-intuitive. I've never seen a command before in my life that deletes the contents of a directory that it doesn't normally concern itself with.

Since the 'functionality' of the 'ng serve' command won't be changed, I'll open separate tickets for the command line option and adding a message informing the user to make it easier.

@filipesilva
Copy link
Contributor

The command line option ( --delete-output-path, which you can set to false) currently exists though, and I don't think a message every time ng build/serve/e2e run is very useful - it just becomes white noise after one or two times.

I do agree that it might be unexpected in some setups (like the one you described), but I think that in a lot of setups it's not surprising at all that the output directory for the build system is wholly transient and that there are a lot of commands to wipe/rebuild it.

You're quite right that this is poorly documented. I'll add a note to the build command docs.

filipesilva added a commit to filipesilva/angular-cli that referenced this issue May 19, 2017
Brocco pushed a commit that referenced this issue May 24, 2017
@vprasanth
Copy link

@filipesilva what version did this go in to?

@EliezerB123
Copy link

Running "ng build --output-path='../'" , instead of creating a directory in the parent named "dist", just deleted 12 hours of my work.

A little warning, or maybe an error message would have been nice.

Instead, AFTER my entire project was deleted, I got a cheery little message saying "Path must be a string. Received null"

dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this issue Apr 23, 2018
@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 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort1: easy (hours) P5 The team acknowledges the request but does not plan to address it, it remains open for discussion severity2: inconvenient
Projects
None yet
Development

No branches or pull requests

5 participants