Fernando Costa
Fernando Costa

Reputation: 699

How to set folders to Angular-Cli commands?

This question is about angular-cli usage.

Is it possible to specify the project folder for running ng commands?

For example:

$ ng build /home/fadc80/my-first-angular-cli-project

Additionally...

Is it possible to specify the output folder too?

For example:

$ ng build /home/fadc80/my-first-angular-cli-project ./build

Thanks!

Upvotes: 0

Views: 582

Answers (2)

Brocco
Brocco

Reputation: 64883

NOTE: This answer does not answer the actual question, but leaving it hear as the build param information may be helpful to those searching and ending up here.

In the file angular-cli.json under apps is a property called outDir which has a default value of dist.

You can customize that value to place the output of your build to wherever makes the most sense for your project.

Furthermore; you can specify the value via the command line with the output-path option:

ng build --output-path build

or via the shortcut o

ng build -o build

Upvotes: 1

Bernie
Bernie

Reputation: 5055

It's not possible directly to build a cli project when you're not inside the projects folder.

Angular cli quits with a useful error message here:

You have to be inside an angular-cli project in order to use the build command.

But to achieve what you want to do you can go this way:

CURRENT_DIR=$(pwd) && \
cd /home/fadc80/my-first-angular-cli-project && \
ng build -o $CURRENT_DIR/build && \
cd $CURRENT_DIR

Upvotes: 3

Related Questions