Guides Eleventy + Tailwind + Vite

Updated December 3, 2026

AI-generated from Mike Stilling's work, notes, and writing.

Eleventy, Tailwind, and Vite

This is part two of a series on the boilerplate behind Mike Stilling's marketing sites. Part one covers WebC components. This part covers the build: Eleventy for pages, Tailwind CSS v4 for styling, and Vite to bundle it all, plus the gotcha that costs everyone an afternoon.

The short answer

Use Eleventy's Vite plugin, add Tailwind's Vite plugin to it, and import Tailwind in one CSS file. Then watch for one thing: Vite only keeps files that an HTML page references, so copy your sitemap, feeds, and other plain files back into the output yourself.

The stack

  • Eleventy turns Markdown and WebC files into static HTML.
  • Tailwind CSS v4 gives you utility classes, configured in CSS instead of a JavaScript config file.
  • Vite bundles CSS and JavaScript, hashes file names for caching, and runs the dev server.
  • Netlify (or Vercel) builds and hosts it. Every push deploys; every branch gets a preview URL.

That's the whole list. Mike's bias is toward as few dependencies as possible. Every package is something to update, and every abstraction is something a new teammate or an AI agent has to understand.

Wiring it up

Install the pieces:

npm install @11ty/eleventy @11ty/eleventy-plugin-vite tailwindcss @tailwindcss/vite

Add both plugins to your Eleventy config:

// eleventy.config.js
import EleventyVitePlugin from "@11ty/eleventy-plugin-vite";
import tailwindcss from "@tailwindcss/vite";

export default function (eleventyConfig) {
    eleventyConfig.addPlugin(EleventyVitePlugin, {
        viteOptions: {
            appType: "mpa",
            plugins: [tailwindcss()],
        },
    });
}

Create one CSS entry file:

/* src/assets/css/main.css */
@import "tailwindcss";

:root {
    --contain: 67rem;
}

Link it from your base layout with a normal <link rel="stylesheet">. Vite finds it, runs Tailwind, and swaps in a hashed file name at build time.

Then two scripts in package.json:

"scripts": {
    "start": "rm -rf dist .11ty-vite && eleventy --serve --incremental",
    "build": "rm -rf dist .11ty-vite && eleventy"
}

Clearing dist and Vite's temp folder before each run prevents stale files from an old build hanging around.

The missing-files gotcha

This one catches nearly everyone. With the Vite plugin, Eleventy builds to a temporary folder and Vite rebuilds the final output from the HTML pages it finds there. Anything no HTML page links to quietly disappears: sitemap.xml, feed.xml, a search index, robots.txt, llms.txt.

The fix is a tiny Vite plugin that copies those files into dist after Vite finishes:

import { cp } from "node:fs/promises";
import { resolve } from "node:path";

function restorePassthroughCopy() {
    let root;
    return {
        name: "restore-passthrough-copy",
        configResolved(config) { root = config.root; },
        async closeBundle() {
            for (const file of ["sitemap.xml", "feed.xml"]) {
                await cp(resolve(root, file), resolve("dist", file));
            }
        },
    };
}

Add it next to tailwindcss() in the Vite plugins list. Images, fonts, and audio can be copied the same way. Check your production build's output folder once after setting this up. The dev server won't show the problem.

Folder structure

A layout that has held up across 5+ sites:

src/
  _components/   WebC components, one per file
  _layouts/      page shells
  _data/         site-wide data: navigation, settings
  assets/        css, js, images, fonts
  blog/          one Markdown file per post
  work/          one file per case study
  index.webc     the homepage
eleventy.config.js

Each section folder can have a folder-name.json file that sets defaults for everything in it, like the layout and tags. New pages then only need their own front matter and content.

Deploying

On Netlify, set the build command to npm run build and the publish directory to dist. Pin your Node version in package.json under engines so local and production builds match. Redirects for moved pages go in netlify.toml. Keep them, because old URLs keep getting search traffic long after you change them.

Making it readable by AI

More people now find things through AI assistants, so this site goes a step further. Every page also publishes a clean Markdown version, and an llms.txt file at the root lists what's on the site. Both are generated by Eleventy templates from the same content, so they never drift from the HTML. Pages also include JSON-LD structured data, such as Article and FAQPage, built from front matter.

None of this needs extra dependencies. It's just a few more Eleventy templates, which is the point of a simple stack: adding something new is easy.

For how the components themselves work, see part one on WebC. To decide whether a code-based site is right at all, see Webflow vs Framer vs code.

Frequently asked questions

How do I add Tailwind CSS v4 to Eleventy?

The simplest route is the Eleventy Vite plugin with Tailwind's Vite plugin. Add tailwindcss() to the Vite plugins in your Eleventy config, create a CSS file that starts with @import "tailwindcss", and link it from your layout. Vite compiles it during the dev server and the production build.

Why are files missing from my Eleventy build after adding Vite?

The Eleventy Vite plugin rebuilds the output from HTML entry points, so files Eleventy wrote that no HTML page references, like sitemap.xml, an RSS feed, or llms.txt, can be dropped. Copy them back in a small Vite plugin hook that runs after the bundle closes, or move them to Vite's public folder.

Do I need Vite to use Tailwind with Eleventy?

No. You can run the Tailwind CLI alongside Eleventy instead. Vite is worth it if you also want bundled JavaScript, hashed asset filenames, and one dev server that handles both.

Is Eleventy good for a SaaS marketing website?

Yes, if someone on the team is comfortable with HTML, CSS, and Git. It outputs plain static files, has very few dependencies, is fast to host on Netlify or Vercel, and doesn't lock you into a platform. Marketers can edit content through a Git-based CMS if needed.

    In this guide