npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vite-plugin-pug

v0.3.2

Published

Vite plugin for transform Pug templates into HTML

Downloads

14,547

Readme

vite-plugin-pug

test

A plugin that makes Vite parse <pug src="example.pug"></pug> in your index.html. The rendered template replaces this tag with the compiled markup.

:information_source: Vue single file components don’t require this plugin, adding Pug to the dependency list is enough. — aka npm i -D pug

Features

  • [x] CommonJS and ES module builds.
  • [x] Handle self-closing pug tags.
  • [x] Works with multiple pug tags.
  • [x] Generated TypeScript declarations.
  • [x] Reload when saving changes on a .pug file.
  • [x] Support Pug local variables.
  • [x] Templates for multiple inputs.
  • [ ] Experimental hot module reloading functionality.
  • [ ] Handle adding or removing files.

Add to a project

Installation

Choose your appropriate choice:

$ npm i -D vite-plugin-pug
$ pnpm add -D vite-plugin-pug
$ yarn add -D vite-plugin-pug

Configuration

Create a vite.config.js configuration file and import the plugin:

// vite.config.(js|ts)
import { defineConfig } from "vite"
import pugPlugin from "vite-plugin-pug"

const options = { pretty: true } // FIXME: pug pretty is deprecated!
const locals = { name: "My Pug" }

export default defineConfig({
  plugins: [pugPlugin(options, locals)],
})

Plugin Parameters

| Name | Required | Description | | ------- | -------- | ----------------------------------------- | | options | optional | Plugin options object. | | locals | optional | Data object with Pug locals. |

Plugin Options

| Name | Required | Description | | ------------ | -------- | --------------------------------------------------------------------------------- | | ... | optional | Anything from Pug options object. | | localImports | optional | If true, use relative imports in the pug src attribute. |

Usage

Simple

Create a template file.

//- index.pug
h1 Hello World
p I'm a cool Vite project!

Embed pug tag with src attribute somewhere.

<!-- index.html -->
<html>
  <body>
    <pug src="index.pug" />
    <script type="module" src="/main.ts"></script>
  </body>
</html>

That's it.

:bulb: Check out its starter implementation in this repository.

Examples

Please find the examples folder in this repository.

Contribution

~~After Rollup~~ I started to use Vite recently but this is not a reason to leave my beloved template format behind. Its lack of active Pug plugins made me make one quickly. It does the job to me, I will extend it when I need it. :suspect:

If it doesn't match with your setup please start a new discussion about it, I'm interested to see other workflows. If something is simply not working, please raise an issue. PRs certainly welcome! (.❛ ᴗ ❛.)