Skip to content

ymulenll/esbuild-plugin-pug

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%