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

1

9

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 :)

Lefevre answered 16/7, 2021 at 6:46 Comment(4)
Where are your assets located relative to your code ?Tout
My assets are in src/mail/templatesLefevre
Okay. For information, the "include" is relative to the sourceRoot of the project's config in nest-cli.json. Could you provide a minimal example of what your nest-cli.json looks like ?Tout
nest-cli.json added above.Lefevre
L
8

Solved by writting the whole path to the file :

"assets": [
  { "include": "mail/sendbox/","watchAssets": true },
]
Lefevre answered 20/7, 2021 at 15:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.