Last updated: Apr 4, 2024
Reading time·2 min
The easiest way to change the dist
folder path in Angular is to use the
--output-path
option when issuing the npx ng build
command.
The option enables you to specify the full path to the new output directory.
npx ng build --output-path=dist/my-output-path
The example command above uses dist/my-output-path
as the dist
directory, so
make sure to update it depending on your needs.
You can also change the dist
folder path directly in your angular.json
file.
The angular.json
file is located in the root directory of your project (where
your package.json
file is).
{ "projects": { "bobbyhadz-angular": { "architect": { "build": { "options": { "outputPath": "dist/my-output-path", } } } } } }
The example sets the dist
folder path to dist/my-output-path
, so make sure
to update it depending on your needs.
Note that the outputPath
property should already be set in your angular.json
file, so you can press Ctrl
+ F
to search for the property and update its
value.
The outputPath
property is located under projects
> your-app
>
architect
> build
> options
> outputPath
.
outputPath
property is set to the name of your app, e.g. dist/bobbyhadz-angular
.This places the outputs of your npx ng build
command in a folder named
dist/bobbyhadz-angular
.
The next time you run the npx ng build
or npm run build
commands, the new
output path will be used.
npx ng build # the same command as above npm run build
I've also written an article on how to change the default port number in Angular.
You can learn more about the related topics by checking out the following tutorials: