Igor Ivanov
Igor Ivanov

Reputation: 63

Angular 6 can't find .angular-cli.json and change the outDir

I have followed an online tutorial which says that I have to set the outDir inside the .angular-cli.json file. This will put the compiled code in the right directory specified in my app.js folder when I run ng build. The problem is I can't find the file anywhere. Tutorial link

The solution is done and has no errors, all I have to do now is connect Angular with the back end I have and run it on localhost:3000. Thus far, I found outdir only in tsconfig.json file. When I run the compiler the files end up in the default dist folder.

Upvotes: 1

Views: 7337

Answers (1)

Vikas
Vikas

Reputation: 12036

The Tutorial you are referring to is using Angular 2 and the latest version of Angular is 6

CLI projects in angular 6 onwards will be using angular.json instead of .angular-cli.json for build and project configuration.

Each CLI workspace has projects, each project has targets, and each target can have configurations.Docs
If you want the generated artifacts to be stored in the custom location Modify the output path from "outputPath": "dist/ng6", to "outputPath": "dist/yourcustomlocation", under build target

    {
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "ng6": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/ng6",**<----/modify this**
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets":

FurtherMore the Tutorial uses HttpModule which is deprecated you should use HttpClientModule instead

Upvotes: 14

Related Questions