我在具有以下结构的文件夹中有邮件模块:
- Mail
- templates
- <Handlebars files>
- mail.module.ts
Run Code Online (Sandbox Code Playgroud)
当我构建(编译)TypeScript 项目时,我的template文件夹不包含在build文件夹中。dist构建时如何将这些文件移入?
开发和生产构建有什么不同吗?
我的文件夹结构类似于下面。
public
views
src
main.ts
/users
users.controller.ts
/views
my-view.hbs
/books
books.controller.ts
/views
my-view.hbs
Run Code Online (Sandbox Code Playgroud)
这是我用来添加模板和视图的
const app = await NestFactory.create<NestExpressApplication>(
AppModule,
);
console.log(join(__dirname, 'public'));
app.useStaticAssets(join(__dirname, '..', 'public'));
app.setBaseViewsDir(join(__dirname, '..', 'views'));
app.setViewEngine('hbs');
hbs.registerPartials(join(__dirname, '..', 'views', 'partials'));
Run Code Online (Sandbox Code Playgroud)
我的 package.json 脚本看起来像这样
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/src/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk …Run Code Online (Sandbox Code Playgroud)