I have the following Firebase function which uses nodemailer to send an email with attachment.
await nodemailer.createTransport(transport).sendMail({
from: from,
to: studentDto.email,
subject: subject,
html: Mail.createInvoice(studentDto, itemDto),
attachments: [{filename: 'file.pdf', path: './assets/file.pdf'}],
});
The PDF is at src/assets/file.pdf
. When I run npm run build
the folder lib
is created but assets/file.pdf
is not included.
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017"
},
"compileOnSave": true,
"include": [
"src"
]
}
How can file.pdf
be included in the build?
CodePudding user response:
Reason
TSC does not include any assets in the build.
Solution
I uploaded the file to Firebase Storage. There I could copy the public url and use it.