pupilx
pupilx

Reputation: 75

Angular, webpack: build project into output path

I need to integrate my application client-side part written in Angular with server-side written in Spring. I would like to build the UI project and save in /target folder inside the backend part, so that I could install it using maven then. I'm not sure whether using ng build --output-path is still the proper way to do this, while I'm working with @angular ^6.1.0, webpack ^2.7.0, node v8.11.3, npm 6.2.0.

Upvotes: 0

Views: 3001

Answers (2)

Ram Chandra Neupane
Ram Chandra Neupane

Reputation: 1891

Easiest configuration is to define where ng build generates app files in angular.json (replaced .angular-cli.json).

 "architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        "outputPath": "dist/your-app-name",
       // Removed unnecessary code

Or you can overwrite the output path using these command line arguments

ng build -op dist/example1
ng build --output-path=dist/example2

And ng build --output-path is also completely valid option.

Upvotes: 3

Shant Marouti
Shant Marouti

Reputation: 1325

Although --output-path is a completely valid option, it's more comfortable to configure it once in the Angular CLI workspace (angular.json) file.

{
  "projects": {
    "project-name": {
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "project-name"
          }
        }
      }
    }
  }
}

Upvotes: 0

Related Questions