0.0.3 • Published 8 months ago

@ymulenll/esbuild-plugin-pug v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

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.",
});
0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago