ng serve removes /dist directory, but I would like to have it under version control
I realize that this is closed, but I keep ending up on this issue while searching for a while to make ng-cli clean everything inside of dist/ but not remove the folder. There's a definite use case for it.
In our case we are building the app with the angular cli and serving it with the nginx docker container. During development, we simply volume map the dist directory of our project to that container so we can see updates without starting the container.
Docker volume mapping strongly disagrees with removing the root volume mapped directory. And yeah we could map the next directory up and use docker trickery to ignore large folders like node_modules.
As another point of interest, we have a separate project where we added webpack manually to an old app, and we had to explicitly tell it to clean dist/* insead of dist/ to solve this problem.
@severin2 the --delete-output-path=false option was added for that specific scenario. See https://github.com/angular/angular-cli/wiki/build for details.
I believe ng serve --delete-output-path false is working for me.
One thing to note that while the flag is documented in the wiki for the build command, it's not documented for serve.
In my situation, once deployed the UI and API run under the same webserver. As part of the build I have a test to verify static content is being served with a no-cache header. That works fine on the build server, but locally I wasn't able to run the test since the dist folder was being removed on ng serve (npm postinstall will stub in a fake file specifically for this test; during the actual build that folder gets replaced)
@filipesilva I'm trying to integrate my angular 4 project in an already existing maven project. I understand the '/dist' folder has to be referenced in the 'target' dir of my maven project. How can this integration be done in this case since angular-cli deletes my dist folder?
@izy2nv Try ng serve --deleteOutputPath=false that worked for me prevention the deletion of my outDir value.
I too got annoyed by that angular/cli screwover, but to me making a custom npm run build was even more convenient since I can use npm run build --prefix from parent folder (which holds many more projects and the actual dist folder), makes my workflow a bit more fluid.
@felyperennan open a new ticket. this one is closed, and as such, it seems the devs stop caring about it.
I'm not asking this to be changed, I think everyone already adapted to this by this point, I'm just adding how a custom npm script can be even more beneficial than having this particular behavior changed. But thanks anyways.
Just want to add my two cents here.
I am developing a desktop app with electron, so I need to keep the dist folder to make electron running, in the meantime, I can run ng server for angular component development.
ng serve --deleteOutputPath=false is good enough for my case.
thanks
it deleted some on my work in progress file and not able to find those files now, not even in recycle bin, Any idea where these files will go after ng build deletes these.
@shoagraw, they are deleted permanently from the filesystem: https://github.com/angular/angular-cli/blob/master/tools/publish/src/build.ts#L75
change /dist to other folder path !
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"
Has the delete-output-path flag been removed in Angular CLI 6.0.0?
It also seems Angular CLI 6.0.0 stopped deleting the "dist" folder by default. Had to add rmdir .\\dist /S /Q && to my npm start script before ng serve, because oddly enough I've depended on the old behavior 🙂
Looks like they learned that side-effects are bad (however well-intentioned):
Before: https://github.com/angular/angular-cli/pull/4293 Code: https://github.com/filipesilva/angular-cli/blob/4a653e2820539cf71faf51ac2e0e195c23a234bd/packages/angular-cli/tasks/serve.ts
After: https://github.com/angular/angular-cli/pull/9883 Code: https://github.com/angular/angular-cli/blob/bc56efa0535fe068b976fffaf3c2e570c967a333/packages/%40angular/cli/commands/serve.ts
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.