@ymulenll/esbuild-plugin-pug
v0.0.3
Published
esbuild plugin to load jade/pug files
Downloads
708
Maintainers
Readme
esbuild-plugin-pug
Import plugin for pug (and jade) files for esbuild
This plugin is based on esbuild-plugin-pug, but instead of returning HTML, it returns the compiled function. This allows you to pass input data to the template, and it also supports includes in your templates.
Install
npm i -D @ymulenll/esbuild-plugin-pug
Use
First add the plugin to esbuild
const pugPlugin = require("esbuild-plugin-pug");
require("esbuild")
.build({
entryPoints: ["index.ts"],
outfile: "out.js",
bundle: true,
platform: "node",
plugins: [pugPlugin()],
})
.catch(() => process.exit(1));
Then, you can import .pug
(and .jade
) files in your code
import compiledFunction from "./template.pug";
compiledFunction({
title: "Hello, world!",
message: "This is a test.",
});