Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NestJS - assets & views folder not being added to dist

Tags:

nestjs

NestJS - assets & views folder not being added to dist folder after build

My folder structure is similar to below:

/assets
  /img
  /fonts

/views
  failure.hbs
  success.hbs

/src
  main.ts
  /users
       users.controller.ts
like image 488
Ron Barak Avatar asked Sep 06 '25 15:09

Ron Barak


2 Answers

You can copy those folders into the dist folder by adding these lines to your nest-cli.json file:

  "compilerOptions": {    
    "assets": [
      {
        "include": "../assets",
        "outDir": "dist/public",
        "watchAssets": true
      },
      {
        "include": "../views",
        "outDir": "dist/views",
        "watchAssets": true
      }
    ],
    "watchAssets": true
  }
like image 88
Amineze Avatar answered Sep 08 '25 11:09

Amineze


I came to this thread for NestJS + EJS Setup (late to the party) and below is my directory structure.

/views
  index.ejs

/src
  main.ts

Note: after changing compilerOptions in "nest-cli.json" fixed the issue.

"compilerOptions": {    
    "assets": [
      {
        "include": "views",
        "outDir": "dist",
        "watchAssets": true
      }
    ],
    "watchAssets": true,
    "deleteOutDir": true
  }
like image 31
Venkat.R Avatar answered Sep 08 '25 11:09

Venkat.R