如何使typescript将.pug文件传输到编译目录
我正在使用云函数来呈现一个html文件,以便通过pug模板引擎发送电子邮件 首先,我试着做以下几点:如何使typescript将.pug文件传输到编译目录,typescript,firebase,google-cloud-functions,pug,Typescript,Firebase,Google Cloud Functions,Pug,我正在使用云函数来呈现一个html文件,以便通过pug模板引擎发送电子邮件 首先,我试着做以下几点: import * as functions from 'firebase-functions'; import * as pug from 'pug'; export const renderHTML = functions.https.onRequest(() => { // Compile the source code const compiledFunction = pug.co
import * as functions from 'firebase-functions';
import * as pug from 'pug';
export const renderHTML = functions.https.onRequest(() => {
// Compile the source code
const compiledFunction = pug.compileFile('email.pug');
// Render a set of data
return compiledFunction({
name: 'Timothy'
});
// "<p>Timothy's Pug source code!</p>"
});
import*作为“firebase函数”中的函数;
从“pug”中导入*作为pug;
export const renderHTML=functions.https.onRequest(()=>{
//编译源代码
const compiledFunction=pug.compileFile('email.pug');
//呈现一组数据
返回编译函数({
名字:“蒂莫西”
});
//“蒂莫西的哈巴狗源代码!”
});
但是,在运行函数时,找不到.pug。我怀疑这是因为它没有在typescript编译到js中进行。那么,我怎样才能让它进入lib文件而不用手动将它放在那里呢
将email.pug放入函数文件夹,而不是src文件夹。文件路径是相对于部署根目录(即函数)获取的。您可以使用其他文件夹,只要您指定了与函数相关的文件夹。这似乎有效。然而。。。当我运行函数时,什么都没有发生,只是超时。你看到代码本身有什么问题吗?我认为这应该行得通…我不知道,我建议发布一个新问题,并附上调试细节。