Wednesday, 26 June 2019

Set "basedir" option for Pug in NestJS

I'm trying to use pug layouts in NestJS, however when extending a layout from an absolute path, pug requires the basedir option to be set.

In ExpressJS you would use app.locals.basedir = ..., what would be the equivalent in NestJS?

const server = await NestFactory.create<NestExpressApplication>(AppModule);
server.setViewEngine('pug');
server.setBaseViewsDir(join(__dirname, 'templates', 'views'));
await server.listen(config.server.port);

Using extends /layouts/index in a view would throw the following; the "basedir" option is required to use includes and extends with "absolute" paths.

I'm not looking to use relative paths, since this quickly becomes very messy. E.g. extends ../../../layouts/index



from Set "basedir" option for Pug in NestJS

No comments:

Post a Comment