【发布时间】:2019-06-28 10:58:17
【问题描述】:
我正在尝试在NestJS 中使用pug 布局,但是当从绝对路径扩展布局时,pug 需要设置basedir 选项。
在 ExpressJS 中你会使用 app.locals.basedir = ...,在 NestJS 中是什么?
const server = await NestFactory.create<NestExpressApplication>(AppModule);
server.setViewEngine('pug');
server.setBaseViewsDir(join(__dirname, 'templates', 'views'));
await server.listen(config.server.port);
在视图中使用extends /layouts/index 会抛出以下内容; the "basedir" option is required to use includes and extends with "absolute" paths.
我不想使用相对路径,因为这很快就会变得非常混乱。例如。 extends ../../../layouts/index
【问题讨论】: