[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live)

[Help](/c/help/9)

# Resolving Unexpected Output Path Errors in Vercel Deployments

103 views · 0 likes · 4 posts


Azziefuzzie (@azziefuzzie) · 2025-09-23

```{

  "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```


Pauline P. Narvas (@pawlean) · 2025-09-24

Hi, @azziefuzzie! Welcome to the Vercel Community. 

It looks like the issue comes from how Eleventy and Vite are handling their output directories. Right now, you have a mismatch:

* Eleventy outputs to `_site`
* Vite outputs to `.11ty-vite`

This conflict prevents Vercel from picking up the correct build output.

Try updating your Eleventy config so that Vite builds to the same directory as Eleventy:

```js
_eleventyConfig_.addPlugin(EleventyVitePlugin, {
  tempFolderName: tempFolder,
  viteOptions: {
    root: "src",
    publicDir: "public",
    build: {
      outDir: path.resolve(process.cwd(), "_site"), // Match Eleventy output
      emptyOutDir: false, // Prevents Eleventy files from being deleted
      rollupOptions: {
        input: {},
      },
    },
  },
});
```

If that doesn't work, try removing the custom `outDir` from your config and let `EleventyVitePlugin` handle it automatically.


Azziefuzzie (@azziefuzzie) · 2025-09-24

Thanks, @pawlean I tried both solutions also tried removing the with removing the    “outDir: path.resolve(process.cwd(), '\_site')”, couldn’t get it to work though still the same error :
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*) {

  // --- Ensure temp folder exists ---

  const tempFolder = '.11ty-vite';

  if (!*fs*.existsSync(tempFolder)) *fs*.mkdirSync(tempFolder, { recursive: true });



  // --- Server ---

  *eleventyConfig*.setServerOptions({ port: 3000 });



  // --- Plugins ---

  *eleventyConfig*.addPlugin(pluginPug);



  *eleventyConfig*.addPlugin(EleventyVitePlugin, {

    tempFolderName: tempFolder,

    viteOptions: {

      root: 'src',

      publicDir: 'public',

      build: {

 

        outDir: path.resolve(process.cwd(), '\_site'),

        emptyOutDir: false, 

        rollupOptions: {

          input: {}, 

        },

      },

      css: {

        preprocessorOptions: {

          scss: {

            additionalData: \`@import "@styles/utils/variables.scss";\`,

          },

        },

      },

      resolve: {

        alias: {

          '@styles': path.resolve(process.cwd(), 'src/styles'),

          '@app': path.resolve(process.cwd(), 'src/app'),

          '@utils': path.resolve(process.cwd(), 'src/app/utils'),

          '@components': path.resolve(process.cwd(), 'src/app/components'),

          '@shaders': path.resolve(process.cwd(), 'src/app/shaders'),

          '@classes': path.resolve(process.cwd(), 'src/app/classes'),

          '@animations': path.resolve(process.cwd(), 'src/app/animations'),

          '@pages': path.resolve(process.cwd(), 'src/app/pages'),

        },

      },

    },

  });



  // --- Passthrough copy ---

  *eleventyConfig*.addPassthroughCopy('public');

  *eleventyConfig*.addPassthroughCopy('src/app');

  *eleventyConfig*.addPassthroughCopy('src/fonts');

  *eleventyConfig*.addPassthroughCopy('src/styles');

  *eleventyConfig*.setServerPassthroughCopyBehavior('copy');



  // --- HTML minify ---

  *eleventyConfig*.addTransform('htmlmin', (*content*, *outputPath*) => {

    if (*outputPath* && *outputPath*.endsWith('.html')) {

      return htmlmin.minify(*content*, {

        useShortDoctype: true,

        removeComments: true,

        collapseWhitespace: true,

      });

    }

    return *content*;

  });



  // --- Return directory config ---

  return {

    dir: {

      input: 'src/views/',

      output: '\_site',

      includes: '\_includes',

      data: '\_data',

    },

    passthroughFileCopy: true,

    htmlTemplateEngine: 'pug',

  };

};


system (@system) · 2026-01-20

Hi @azziefuzzie! 🔔

This thread's been quiet for a while. If you're still facing issues, please share any relevant details (logs, screenshots, error messages) so we can take another look!