Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove dist files in Angular 6?

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 ?

like image 760
The Dead Man Avatar asked Mar 06 '23 23:03

The Dead Man


2 Answers

Simplest solution on Windows

rd /s dist 

and on Linux

rm -r dist
like image 97
Kamil Naja Avatar answered Mar 16 '23 13:03

Kamil Naja


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.

like image 38
feder Avatar answered Mar 16 '23 13:03

feder