How to change ng build output directory

Last modified date

Comments: 0

Problem

By default when you run the ng build command on your Angular project using the Angular CLI it will output the build files to the /dist directory.

This can be inconvenient if you have automated pipelines and want to be able to write out different environment builds to different directories.

However there is an option that you can pass into the ng build command to specify the output directory.

Solution

If you wanted to write your code to a directory called /dist-stage for example, you can use the --output-path option to specify where to write the build files out to:

ng build --output-path dist-stage

The Angular CLI will build the Javascript, HTML and other asset files to a new directory /dist-stage that you passed in as an option.

References

https://angular.io/cli/build

JakTech

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.