TS compiler doesn't handle files that are other than TypeScript or JS (e.g. .ts
, .js
, .tsx
, etc.).
One way of doing it, just running cp
to copy those files after you compile NestJS. In your package.json
replace the line
"build": "nest build",
with
"build": "nest build && cp ./Mail/templates ./build",
Ideally, I would switch to Webpack (or similar) to transpile TypeScript and copy artifacts. NestJs has a basic example on how to build with Webpack here. To extend it to have a "copy" phase, install copy-webpack-plugin
npm package and add those additions in webpack config file:
const copyFiles = require('copy-webpack-plugin');
// ... omitted for abbreviation
module.exports = function(options) {
return {
// ... omitted for abbreviation
,
plugins: [
// ... omitted for abbreviation
new copyFiles([
{ from: 'Mail/templates', to: 'templates' }
])
]
}