11

Angular generates a lot of trash from a .ts file.

app.component.js
app.component.spec.js.map 
app.component.js.map
app.component.spec.ts     
app.component.spec.js

Is there any simple way to delete of that, a lot of build systems support clean,

make clean
git clean

How do you do this in angular

My test case.

  1. Download Angular's Hero Demo toh-3
  2. Unzip it
  3. Jump into the directory
  4. Run npm install
  5. Run npm start

Now from the main.ts you now have main.js and main.js.map

In my own project, where I'm working along with the angular-cli, I actually have .spec files too.

4 Answers 4

3

Check this method

I make build: ng build --env prod which will write it under dist folder Then I run ng serve and my build is gone.

Sign up to request clarification or add additional context in comments.

Comments

1

Are you using the Angular CLI? If so, by default it no longer generates all of these "trash" files.

4 Comments

This should be comment. But, by any means I updated the question with my test case and example.
I'm on the Angular doc team and as far as I know, the Tour of Hero's tutorial is still using systemjs and manually creating the files. It has not yet been updated to using the Angular CLI. If you are using the latest version of the CLI for your own project, you should not be seeing the .js and .map files.
You're actually correct (though this should still be a comment :) ). I started this a few days ago, and I did so from the github seed, angular.io/guide/setup Be great if that was updated at least.
But is this not then the answer to your question? And I completely agree ... we have updating the TOH to the CLI on our todo list.
0

As a matter of trivia, the Tour of Hereos demo was not created (yet) with the Angular CLI but it is set to change. To remove the build files, I've been using this.

find ./src/ -name '*.ts' -print0  |
  sed -z -e's/\.ts$/.*$/' |
  xargs -0 -I pattern find ./src -type f -not -name '*.ts' -regex pattern -exec rm {} \;

Comments

0

build file location refrence is in memory, in task manager clean all node.exe.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.