"version": 2,
"builds": \[
{
"src": "package.json",
"use": "@vercel/static-build",
"config": {
"distDir": "\_site"
}
}
\],
"rewrites": \[
{
"source": "/api/:path\*",
"destination": "/src/views/api/:path\*.js"
},
{
"source": "/product/:uid",
"destination": "/index.html"
},
{
"source": "/(.\*)",
"destination": "/index.html"
}
\],
"headers": \[
{
"source": "/index.html",
"headers": \[
{
"key": "Cache-Control",
"value": "no-store, no-cache, must-revalidate"
},
{
"key": "Pragma",
"value": "no-cache"
},
{
"key": "Expires",
"value": "0"
}
\]
}
\]
}
import path from "path";
import fs from "fs";
import htmlmin from "html-minifier";
import EleventyVitePlugin from "@11ty/eleventy-plugin-vite";
import pluginPug from "@11ty/eleventy-plugin-pug";
export default function (*eleventyConfig*) {
// Temp folder for Vite
const tempFolder = ".11ty-vite";
if (!*fs*.existsSync(tempFolder)) *fs*.mkdirSync(tempFolder, { recursive: true });
// Plugins
*eleventyConfig*.addPlugin(pluginPug);
*eleventyConfig*.addPlugin(EleventyVitePlugin, {
tempFolderName: tempFolder,
viteOptions: {
root: "src",
publicDir: "public",
build: {
outDir: path.resolve(process.cwd(), ".11ty-vite"), // <- add this
emptyOutDir: true,
rollupOptions: {
input: {},
},
},
}
});
// Passthrough copy
*eleventyConfig*.addPassthroughCopy("public");
*eleventyConfig*.addPassthroughCopy("src/fonts");
*eleventyConfig*.addPassthroughCopy("src/app");
// HTML minify
*eleventyConfig*.addTransform("htmlmin", (*content*, *outputPath*) => {
if (*outputPath* && *outputPath*.endsWith(".html")) {
return htmlmin.minify(*content*, {
useShortDoctype: true,
removeComments: true,
collapseWhitespace: true,
});
}
return *content*;
});
// Directory config
return {
dir: {
input: "src/views",
output: "\_site",
includes: "\_includes",
data: "\_data",
},
passthroughFileCopy: true,
htmlTemplateEngine: "pug",
pathPrefix: "/", // important for root-relative links
};
}; "scripts": {
"prebuild": "mkdir -p .11ty-vite && rimraf \_site",
"build:vercel": "pnpm run prebuild && npx eleventy --config=.eleventy-build.js",
"vercel-build": "pnpm run build:vercel",
"build:win": "powershell -ExecutionPolicy Bypass -File build.ps1",
"dev": "eleventy --config=.eleventy.js --serve --incremental",
"clean": "rimraf \_site .11ty-vite"
},
I dont understand why I keep getting this error Error: Unexpected output path (was not in output directory \_site): ./\_site/about/index.html