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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ulu/vite-plugin-eleventy

v0.0.1

Published

Integrates Eleventy into Vite, providing HMR for development and automatic asset hashing for production builds.

Readme

@ulu/vite-plugin-eleventy

Integrates Eleventy with Vite for development and production workflows.

Overview

This plugin manages the Eleventy lifecycle within Vite:

  • Development: Runs Eleventy in watch mode and serves the output via Vite middleware.
  • Production: Orchestrates the Eleventy build after Vite assets are bundled.
  • Assets: Provides helpers to link to Vite-managed assets, handling hashing (production) and source paths (development).

Features

  • Zero Config Injection: Injects necessary configuration into Eleventy via the Programmatic API.
  • Dev Server: Serves Eleventy output from a hidden cache directory.
  • Reloads: Triggers Vite full-page reloads on HTML changes.
  • Asset Helpers: Shortcodes/Filters for script and link tags that respect the Vite manifest.

Installation

npm install @ulu/vite-plugin-eleventy --save-dev

Usage

1. Configure Vite

Add the plugin to your vite.config.js:

// vite.config.js
import { defineConfig } from "vite";
import eleventyPlugin from "@ulu/vite-plugin-eleventy";

export default defineConfig({
  plugins: [
    eleventyPlugin({
      // Path to your Eleventy config file
      configPath: "./eleventy.config.js",
      
      // Optional: Override the base URL for generated asset links.
      // Defaults to Vite's 'base' config.
      // Example: Set to "/" to force root-relative paths if Vite base is "./"
      // publicPath: "/" 
    })
  ],
  build: {
    outDir: "dist", // Vite builds assets here (standard)
    manifest: true, // Required for production asset hashing
    rollupOptions: {
      input: "src/main.js" // Your entry point
    }
  }
});

2. Configure Eleventy

You do not need to manually add a plugin in your eleventy.config.js. The Vite plugin injects itself automatically.

⚠️ IMPORTANT WARNING

Ensure your eleventy.config.js does NOT hardcode a dir.output directory. The plugin must control the output directory:

  • Development: It needs to write to a hidden cache directory.
  • Production: It needs to write to the Vite build directory.

If you hardcode output: "dist", the dev server will not find your files!

// eleventy.config.js
module.exports = function(eleventyConfig) {
  // ... your config
  return {
    dir: {
      input: "src",
      // DO NOT set output here!
      // output: "dist" 
    }
  };
};

3. Use in Templates

Use the provided Shortcodes and Filters to reference your assets. They automatically switch between local paths (Dev) and hashed paths (Prod).

Scripts:

<!-- Output <script type="module" src="..."> -->
{{ viteEntry("site/src/main.js") | safe }}

Styles (CSS):

<!-- In <head>: Output <link rel="stylesheet"> for any CSS associated with the entry -->
<!-- Note: In Dev, Vite injects CSS via JS, so this outputs nothing. -->
{{ viteEntryStyles("site/src/main.js") | safe }}

Raw URL (Advanced):

<!-- Get just the URL string -->
<link rel="preload" href="{{ 'src/main.js' | viteEntryUrl }}" as="script">

Configuration Options

The plugin accepts the following options:

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | configPath | String | "eleventy.config.js" | Path to your Eleventy configuration file (relative to project root). | | outDir | String | viteConfig.build.outDir | The directory where Eleventy should write its output in Production. Usually defaults to Vite's output directory. | | cacheDir | String | node_modules/.@ulu-cache-vite-plugin-eleventy | The directory where Eleventy writes output in Development. Hidden by default. | | publicPath | String | viteConfig.base | The URL prefix for assets (e.g. / or /assets/). Used to construct absolute URLs for {% viteEntry %}. Defaults to Vite's base config. | | debug | Boolean | false | Enable verbose logging. |

How it Works

  1. Development (vite dev):

    • Starts Eleventy in watch mode.
    • Writes HTML to a hidden cache directory.
    • Vite Middleware intercepts requests and serves HTML from the cache.
    • {% viteEntry %} outputs paths to source files (e.g., /src/main.js), allowing Vite to handle HMR.
  2. Production (vite build):

    • Vite builds your assets (JS/CSS) first.
    • Plugin waits for closeBundle hook.
    • Plugin runs Eleventy build.
    • {% viteEntry %} reads manifest.json generated by Vite and outputs hashed paths (e.g., /assets/main.a8b3f.js).