Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Capacitor does not find index.html for a Vue app inside Laravel

ErrorCapacitor cannot find index.html in webDir

Short answer

Capacitor copies the folder named in webDir, and that folder must hold the final index.html. A Laravel project serves its HTML through Blade, so its Vite build writes assets and a manifest, not an index.html. Build the Vue app as a standalone Vite project, or point webDir at a folder that really contains index.html.

  • Applies to Capacitor 7, Vite 7, Vue 3, Laravel 12, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print your webDir and list that folder. If index.html is not in the list, one of the causes below applies.

    grep -n "webDir" capacitor.config.*
    ls dist
  2. 2Match what you see, then jump to its fix

    1. 1The folder named in webDir is missing, or you did not run the build before syncing.webDir points to a folder that does not exist or is emptyFix
    2. 2The Laravel build output holds a manifest and hashed assets, and no index.html; the page is a Blade view.The Vue app is built by Laravel's Vite plugin, which produces no index.htmlFix
    3. 3The app tries to load a URL, not the copied files.A live-reload server URL is set in the Capacitor configFix

What does the error look like?

  • Capacitor cannot find index.html in webDir
  • the web app files are not found by Capacitor after npx cap sync

Cause 1 of 3

webDir points to a folder that does not exist or is empty

1Check

webDir is the directory of your compiled web assets and it should contain the final index.html. Vite writes to dist unless build.outDir says otherwise.

grep -n "webDir" capacitor.config.*
grep -n "outDir" vite.config.*

2Fix

Make webDir equal to the real build output folder, then build and sync in that order.

// capacitor.config.ts
const config = { appId: 'com.example.app', appName: 'App', webDir: 'dist' };
export default config;

# then
npm run build
npx cap sync

3Verify

index.html is in the folder and sync completes.

ls dist/index.html && npx cap sync

Confirmed by capacitorjs.com

Did this fix it?

Cause 2 of 3

The Vue app is built by Laravel's Vite plugin, which produces no index.html

1Check

In Laravel the HTML comes from a Blade template with the Vite directive, and the plugin writes a manifest and a build directory (buildDirectory option). The build is meant for the Laravel server.

grep -n "buildDirectory\|laravel(" vite.config.*

2Fix

Create a standalone Vue project (or a second Vite config) with its own index.html that calls your Laravel API, and give Capacitor that project's build folder as webDir.

// vite.config.js of the standalone Vue app
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
export default defineConfig({ plugins: [vue()], build: { outDir: 'dist' } });

3Verify

After npm run build, dist/index.html exists.

npm run build && ls dist/index.html

Confirmed by laravel.com

Did this fix it?

Cause 3 of 3

A live-reload server URL is set in the Capacitor config

1Check

server.url loads an external URL in the web view. It is intended for live-reload servers and not for production.

grep -n "url\|cleartext" capacitor.config.*

2Fix

Remove server.url from the config you build releases with.

// capacitor.config.ts: delete the server block
// server: { url: 'http://192.168.1.10:5173', cleartext: true }

3Verify

Run npx cap sync and open the app with the built files.

npx cap sync

Confirmed by capacitorjs.com

Did this fix it?

How do I stop it coming back?

  • Keep the mobile web app in its own folder with its own package.json and index.html.
  • Run the build and cap sync together in one script.
  • Keep server.url only in a dev config file.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Expo says it is unable to find expo in this project

Unable to find expo in this project - have you run yarn / npm install yet?

The Expo CLI ships inside the expo package, so the project must have expo as a dependency and installed in its own node_modules.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.