Search code examples
typescriptcompilationhandlebars.jsnestjsmailer

Configure nest-cli.json to include non TS file into the dist folder


I'm looking for a solution for several hours now:

I'm creating an email service with nestJS and nest mailer. Everything work find until I want to include a template with my mail. Those templates are hbs files located in src/mail/templates I know that nest doesn't include non TS files when compile so:

I tried to configure the nest-cli.json, following this link added :

    "compilerOptions": {
"assets":["**/*.hbs"],
"watchAssets": true,
} 

OR

"assets": [
  { "include": "**/*.hbs","watchAssets": true },
]

My nest-cli.json file looks like this:

{
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
  "assets": [
      { "include": "**/*.hbs","watchAssets": true },
    ]
}

}

But nothing is copied into the dist folder. So I solve this with a modification of the package.json, added a cp command to do it manually but I don't think this is the right way do do it... Is anyone figured out include some non TS files with the assets

PS: hbs is for handlebar (mail templating)

Thanks for your help :)


Solution

  • Solved by writting the whole path to the file :

    "assets": [
      { "include": "mail/sendbox/","watchAssets": true },
    ]