Answer the question
In order to leave comments, you need to log in
How to make webpack and jade(pug) friends?
There is already an assembly on webpack, it was necessary to use some kind of template engine instead of html, so how do they work?
It says here, https://github.com/pugjs/pug-loader
var template = require("pug!./file.pug");
// => returns file.pug content as template function
// or, if you've bound .pug to pug-loader
var template = require("./file.pug");
var locals = { /* ... */ };
var html = template(locals);
// => the rendered HTML
Answer the question
In order to leave comments, you need to log in
Если на примере pug-loader, то вот так.
В webpack.config.js :
Не забываем про file-loader:
Картинки и прочее в .pug с таким pug-loader придется вставлять так:
Если шаблон вставляется в Angular, то придется подключать так:
@Component({
selector: 'app-home',
template: require('./home.component.pug')(),
})
В переменной html и будет отрендеренный html. Выводите его туда, куда нужно.
Подробнее, как использовать loaders - написано в доках: https://webpack.github.io/docs/using-loaders.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question