gidaban79's avatar

After building assets vue files can`t be found

Hello guys.

my app.js file

Vite.config.js

When i am run npm run dev all works well. However when i am building assets npm run build then error appear Unable to locate file in Vite manifest: resources/js/Pages/Index.vue.

Any ideas what can be wrong there ?

0 likes
2 replies
LaryAI's avatar
Level 58

The issue you're encountering is related to Vite's handling of dynamic imports and the way it generates the manifest during the build process. When using import.meta.glob, Vite needs to know all the files at build time to include them in the manifest. If a file is missing from the manifest, it usually means Vite couldn't find it during the build process.

Here are a few steps you can take to resolve this issue:

  1. Check File Paths: Ensure that the file paths in your import.meta.glob call are correct and that the files actually exist in the specified directory. The path should be relative to the file where the import.meta.glob is used.

  2. Ensure Eager Loading: You are already using {eager: true} in your import.meta.glob call, which is good. This ensures that all the files are imported at build time. Double-check that all files are being correctly imported.

  3. Vite Configuration: Make sure your Vite configuration is correctly set up to handle Vue files and that there are no issues with the laravel-vite-plugin or any other plugins you are using.

  4. Clear Cache: Sometimes, clearing the cache can help resolve issues with stale data. Try deleting the node_modules and dist directories, then reinstalling dependencies and rebuilding:

    rm -rf node_modules
    rm -rf dist
    npm install
    npm run build
    
  5. Check for Errors: Look for any errors or warnings during the build process that might give you more information about what's going wrong.

  6. Manifest File: After running npm run build, check the manifest.json file generated by Vite in the dist directory. Ensure that all your Vue components are listed there. If not, there might be an issue with how the files are being imported.

  7. Update Dependencies: Ensure all your dependencies are up to date, especially Vite and related plugins. Sometimes, issues are resolved in newer versions.

If none of these steps resolve the issue, consider creating a minimal reproduction of the problem and sharing it for further assistance. This can help isolate the issue and make it easier to diagnose.

gidaban79's avatar

I have spotted. My all compiled files are in public/build/asset/ folder.

import './bootstrap';
import {createApp, h} from 'vue';
import {createInertiaApp, Head, Link} from '@inertiajs/vue3';
import {ZiggyVue} from 'ziggy-js';
import {createBootstrap} from 'bootstrap-vue-next';
import {resolvePageComponent} from "laravel-vite-plugin/inertia-helpers";

const appName = import.meta.env.VITE_APP_NAME || 'Laravel';

createInertiaApp({
  progress: {
    color: "blue",
  },
  title: (title) => `${title} - ${appName}`,
  resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
  setup({el, App, props, plugin}) {
    return createApp({render: () => h(App, props)})
      .component('Link', Link)
      .component('Head', Head)
      .use(plugin)
      .use(ZiggyVue)
      .use(createBootstrap())
      .mount(el);
  },
});

This set up, proper rendering all assets. However i want to implement layouts. Like default layout and use

defineOptions({
  layout: DifferentLayout,
});

Please or to participate in this conversation.