首页 > 解决方案 > 配置nest-cli.json以将非TS文件包含到dist文件夹中

问题描述

我现在正在寻找几个小时的解决方案:

我正在使用nestJS 和nest mailer 创建电子邮件服务。一切正常,直到我想在我的邮件中包含一个模板。这些模板是位于 src/mail/templates 中的 hbs 文件,我知道在编译时嵌套不包含非 TS 文件:

我尝试配置nest-cli.json,添加以下链接

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

或者

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

我的 nest-cli.json 文件如下所示:

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

}

但是没有任何东西被复制到 dist 文件夹中。所以我通过修改 package.json 来解决这个问题,添加了一个手动执行的 cp 命令,但我认为这不是正确的方法......有没有人想出在资产中包含一些非 TS 文件

PS:hbs 用于车把(邮件模板)

谢谢你的帮助 :)

标签: typescriptcompilationhandlebars.jsnestjsmailer

解决方案


通过写入文件的整个路径来解决:

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

推荐阅读