Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to specify delete-output-path?

I have a Node Express project with Angular added through Angular CLI, ie ng new.

I do not want the Angular output to wipe out the distribution folder.

I understand there is a delete-output-path parameter that can be put on the command line to ng build.

Is it possible to put this in angular-cli.json?

Or should it be in tsconfig.json? Under which property?

like image 594
Old Geezer Avatar asked Apr 02 '18 07:04

Old Geezer


People also ask

What is output hashing in angular?

--output-hashing all — hash contents of the generated files and append hash to the file name to facilitate browser cache busting (any change to file content will result in different hash and hence browser is forced to load a new version of the file)

What does ng build do?

ng buildlink. Compiles an Angular application or library into an output directory named dist/ at the given output path.


2 Answers

For Angular CLI 6+ you have to edit angular.json file. You have to set deleteOutputPath false in build options

"architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        "outputPath": "../dist",
        "deleteOutputPath": false,   <--------------------------- put here
        "index": "src/index.html",
like image 96
Kabir Avatar answered Sep 18 '22 11:09

Kabir


Yes, you can. You have to put it under defaults property of .angular-cli.json like this:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "project-name"
  },
  "apps": [
    {// app property values here}

  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "scss",
    "component": {},
    "serve": {
      "port": 3000
    },
    "build": {
      "deleteOutputPath": false
    }
  }
}

If you want to learn more about this file's structure, you can go here

Hope it helps :)

like image 37
Akanksha Gaur Avatar answered Sep 18 '22 11:09

Akanksha Gaur