M
M
monochromer2017-02-08 13:29:08
JavaScript
monochromer, 2017-02-08 13:29:08

How to precompile Pug (Jade) templates in a NodeJS + Express.js application?

Hello!
There is a web application running in Node.js + Express.js + Pug bundle . You can set the environment variable " NODE_ENV=production ", then the Pug template engine will cache already compiled templates. But I want to immediately slip the precompiled application templates so that the optimization is already on the 1st launch.
How can I do that?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex, 2017-02-08
@streetflush

what for? Write static right away!

M
monochromer, 2017-02-10
@monochromer

In general, the options, as I understand it, are:
1. Accept and just use the environment variable "NODE_ENV=production"
2. Use the express-pug-cache-helper package . But here we need 2 instances of express. One is for basic work, the other is for template caching.
3. Use precompilation of templates with crutches, then replace the template engine with production.

D
Dmitry Makarov, 2018-07-12
@MDiMaI666

Sending an empty request is not an option?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question