1

I have an Angular 2 project generated with the Angular CLI (by typing ng new myProject).

How can I configure the build location, so after the build I will have a separate folder with all HTML, JS and other resources?

3
  • 1
    So, you would want another directory than the default dist directory? Why not copy the contents of dist where you want it after the build instead? Commented Jan 1, 2017 at 12:48
  • 2
    The CLI already does this, that's what ng build is for. If you want to change the output directory, look in angular-cli.json. Commented Jan 1, 2017 at 12:56
  • Yes, the solution was to edit outDir in angular-cli.json file. Thanks! Commented Jan 1, 2017 at 14:56

2 Answers 2

5

2 Steps:

  1. Edit outDir in angular-cli.json file.

enter image description here

(In this case the build will be located in "static" folder one step above project root directory)

  1. Type ng build in the project root directory.
Sign up to request clarification or add additional context in comments.

1 Comment

In Angular 6 onwards this configuration file is angular.json and it is outputPath rather than outDir.
5

The answer by Tomas Marik is correct for cases where you always want to use that output folder. But for cases where you need to be more flexible, you can also override the .angular-cli.json value by specifying it on the command line. This works for both ng build and ng serve:

ng build --output-path ../path/to/use

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.