You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ng serve removes /dist directory, but I would like to have it under version control #4366
@grizzm0 because dist is synonym of an actual build, and it is, ng serve serves the actual code base, but not the build, build is done once per week, month, etc. and has nothing to do with a current working directory. Another synonym of a dist is release, a lot of packages/libraries put their releases under dist directory and have it under version control.
Also, having dist under VCS allows us to keep everything in one place.
ng serve should accomplish its own task => serve actual code. And suddenly it starts to remove files from the outside? this is weird, the other developer was confused, to get rid of a confusion it is enough to understand that there is nothing under dist directory when ng serve is running, README can be updated to clarify this.
At least, removing dist should not be a default behavior, can be achieved by specific configuration option or a command argument.
Thanks.
Reacted by Laurent Direr, Jake Niemiec, Peter Balogh, Taner Yılmaz, Sergey Cherentaev, Juan Carlos, krishna Puppala, jaltamir, Yunior González Santana, Reinier Nápoles Martínez and 9 more
@grizzm0 then, why to have a dist folder at all? what is a purpose of it? temporary folder for temporary content? let`s take a look at scenario:
I make build: ng build --env prod which will write it under dist folder
Then I run ng serve and my build is gone... wow
Why do I stop ng serve at all to make a build?
Reacted by Jason, Taner Yılmaz, Seid M, jaltamir, Harish Kumar, Sergei Prohhorov, Yunior González Santana, Frantisek Skorunka, Alex Mackinnon, Isaac Diaby and 12 more
@grizzm0 what will happen if build was not successful? for any reason, build can output files successfully, but they may not work (e.g. local build is ok, but there is something wrong with prod one).
I believe each command should remove/update only files this command is working with. ng build can clean build directory, but not other command.
Reacted by André Werlang, Anderson Koester, Teng Zhang, vip32, Jason, Bobyshev Nikita, Matthias Schelling, SQL Solver, Eduard Kolosovskyi, Peter Balogh and 29 more
If tests fail during deploy the deploy will be cancelled. If it builds successfully but something is wrong I would either store x releases on the prod machine or rollback by checking out a previous tag and build from that.
Having the latest production build in /dist was part of my build process too. By setting up a command in package.json as @Hinol suggested that sends it to a custom folder (/dist-prod/), I can live with it, minimal changes elsewhere.
My command is: "build-prod": "ng build --prod --env=prod --output-path=dist-prod/" note the extra --prod flag, which does the uglifying and tree shaking.
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 🙂
Activity
grizzm0 commentedon Feb 2, 2017
This was done on purpose in #4293. Any reason why you would want dist in VCS?
Without a build before committing the build would be out of sync with the current revision anyhow.
stepanzarubin commentedon Feb 3, 2017
@grizzm0 because dist is synonym of an actual build, and it is,
ng serveserves the actual code base, but not the build, build is done once per week, month, etc. and has nothing to do with a current working directory. Another synonym of a dist isrelease, a lot of packages/libraries put their releases underdistdirectory and have it under version control.Also, having dist under VCS allows us to keep everything in one place.
stepanzarubin commentedon Feb 3, 2017
ng serveshould accomplish its own task => serve actual code. And suddenly it starts to remove files from the outside? this is weird, the other developer was confused, to get rid of a confusion it is enough to understand that there is nothing underdistdirectory whenng serveis running,READMEcan be updated to clarify this.At least, removing dist should not be a default behavior, can be achieved by specific configuration option or a command argument.
Thanks.
grizzm0 commentedon Feb 3, 2017
It was changed as alot of people thought ng serve would serve the dist folder if present.
@filipesilva You got any input on this?
stepanzarubin commentedon Feb 3, 2017
@grizzm0 then, why to have a
distfolder at all? what is a purpose of it? temporary folder for temporary content? let`s take a look at scenario:ng build --env prodwhich will write it underdistfolderng serveand my build is gone... wowWhy do I stop
ng serveat all to make a build?grizzm0 commentedon Feb 3, 2017
Build is part of my deploy flow. I guess that's how most people use it.
stepanzarubin commentedon Feb 3, 2017
@grizzm0 what will happen if build was not successful? for any reason, build can output files successfully, but they may not work (e.g. local build is ok, but there is something wrong with prod one).
stepanzarubin commentedon Feb 3, 2017
I believe each command should remove/update only files this command is working with.
ng buildcan clean build directory, but not other command.grizzm0 commentedon Feb 3, 2017
If tests fail during deploy the deploy will be cancelled. If it builds successfully but something is wrong I would either store x releases on the prod machine or rollback by checking out a previous tag and build from that.
stepanzarubin commentedon Feb 3, 2017
The world is not perfect, tests does not cover everything perfectly, some people do not write tests.
grizzm0 commentedon Feb 3, 2017
You could still rollback by tag or keep releases on your prod server. :p
filipesilva commentedon Feb 3, 2017
I'm sorry this change disrupted your workflow. We're not looking at changing it back though.
dist/had, at best your lastng buildand was never reflective ofng serve.My recommendation for your particular case is to do make a build using the
--output-path (-op)flag and keep that one under version control.mzeromski commentedon Mar 7, 2017
My solution for this:
After update Jan 2017 noticed new problem. Command ng serve remove /dist dir.
Solution:
File: package.json (new command prod-build)
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"prod-build": "ng build --output-path=last-build/ --env=prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
File: angular-cli.json (change ourDir)
"outDir": "/tmp/dist",
To build your prod version run: npm run prod-build
To serve: ng serve
In this configuration: ng server will create tmp dir, and your project directory will be clean, even when you commit changes without stop ng serve.
lgellert commentedon Apr 12, 2017
Having the latest production build in /dist was part of my build process too. By setting up a command in package.json as @Hinol suggested that sends it to a custom folder (/dist-prod/), I can live with it, minimal changes elsewhere.
My command is:
"build-prod": "ng build --prod --env=prod --output-path=dist-prod/"note the extra --prod flag, which does the uglifying and tree shaking.20 remaining items
EliezerB123 commentedon Mar 18, 2018
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"
docs(@angular/cli): document output dir deletion
michaelb-01 commentedon May 9, 2018
Has the delete-output-path flag been removed in Angular CLI 6.0.0?
rsheptolut commentedon May 9, 2018
It also seems Angular CLI 6.0.0 stopped deleting the "dist" folder by default. Had to add
rmdir .\\dist /S /Q &&to my npmstartscript beforeng serve, because oddly enough I've depended on the old behavior 🙂jakeNiemiec commentedon May 9, 2018
Looks like they learned that side-effects are bad (however well-intentioned):
Before: #4293
Code: https://github.com/filipesilva/angular-cli/blob/4a653e2820539cf71faf51ac2e0e195c23a234bd/packages/angular-cli/tasks/serve.ts
After: #9883
Code: https://github.com/angular/angular-cli/blob/bc56efa0535fe068b976fffaf3c2e570c967a333/packages/%40angular/cli/commands/serve.ts
por favor não apague o meu diretório de build
ci(docs-infra): run PWA score tests after unit/e2e tests (#31047)
ci(docs-infra): run PWA score tests after unit/e2e tests (#31047)
angular-automatic-lock-bot commentedon Sep 8, 2019
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.