How to remove dist files in Angular 6?
Solution 1
Simplest solution on Windows
rd /s dist
and on Linux
rm -r dist
Solution 2
There is a flag for this. See angular.io/cli/build
--delete-output-path true
I use
"build:dev": "ng build --configuration dev --delete-output-path true"
Solution 3
Since you are using package.json AND to be operating system safe I recommend rimraf. It's not only about Windows vs Linux. Also about Linux Distribution vs Linux Distribution, changing access rights, etc. You are safe with this extra layer of abstraction.
Install:
npm install rimraf
In your scripts section of package.json add it as first command and append what ever you want to do after the &&
:
"scripts": {
"ng": "rimraf /dist && ng build"
}
Invoke the build/serve:
npm run ng
ng
is what you defined as your script execution identifier.
The Dead Man
Updated on June 04, 2022Comments
-
The Dead Man almost 2 years
I want to deploy my angular project i generated dist file in my src folder like this
ng build
Before deploying I decided to add some functionality to my page :
Question Is it posible to update dist files by doing like this?
ng serve update /dist dir
if false I want to delete the dist file and create another one so that it can be update with all folders, this is what I wanna do
ng serve remove /dist dir
Is this the right way of removing dist files ?
-
The Dead Man almost 6 yearsdzieki stary ! :)