it-is-all-about-laravel's avatar

herd / inertia / vue - build

i've created an laravel 12 +inertia+vue project via herd on windows. on my local machine i can view the project in web browser, but when i make changes to vue components i do not see the changes take affect in the web browser.

i tried npm run dev in the terminal, that seems to execute with vite reporting it's ready. however that made it worse - as soon as vite is running i get a black screen in the web browser, when i stop the npm run dev process i started i can see the app in the browser again

what do i need to do so see my vue updates in the browser?

0 likes
6 replies
LaryAI's avatar
Level 58

To resolve the issue of not seeing changes to your Vue components in a Laravel + Inertia + Vue project, you can follow these steps:

  1. Ensure Vite is Properly Configured: Make sure your vite.config.js is correctly set up for a Laravel project. It should look something like this:

    import { defineConfig } from 'vite';
    import laravel from 'laravel-vite-plugin';
    import vue from '@vitejs/plugin-vue';
    
    export default defineConfig({
        plugins: [
            laravel({
                input: ['resources/js/app.js'],
                refresh: true,
            }),
            vue(),
        ],
    });
    
  2. Check Your app.js Entry Point: Ensure that your resources/js/app.js file is correctly importing and initializing your Vue components. It should look something like this:

    import { createApp, h } from 'vue';
    import { createInertiaApp } from '@inertiajs/vue3';
    import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
    
    createInertiaApp({
        resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
        setup({ el, App, props, plugin }) {
            createApp({ render: () => h(App, props) })
                .use(plugin)
                .mount(el);
        },
    });
    
  3. Run Vite in Development Mode: Use npm run dev to start Vite in development mode. This should enable hot module replacement (HMR), allowing you to see changes without refreshing the browser.

  4. Check for Console Errors: If you see a black screen, check the browser console for any errors. This can provide clues about what might be going wrong.

  5. Clear Cache: Sometimes, caching issues can prevent changes from appearing. Clear your browser cache or try accessing the site in an incognito window.

  6. Ensure Node Modules are Up-to-Date: Run npm install to ensure all your dependencies are up-to-date. Sometimes, outdated packages can cause issues.

  7. Check Network Configuration: If you're using a tool like Herd, ensure that your network configuration allows for the Vite development server to be accessed. You might need to adjust your firewall or proxy settings.

By following these steps, you should be able to see your Vue component changes reflected in the browser. If the issue persists, consider checking the Laracasts forum or other community resources for additional troubleshooting tips.

it-is-all-about-laravel's avatar

i found npm run build processes and when i refresh in the browser i can see the updates i made are applied

it seems the issue is with dev, how do i fix it so i can get hot reloading of vue updates during development?

lukgol26's avatar

i did npm run build and changes are not visible in browser

RemiM's avatar

Just to be sure, when you run npm run dev you don't stop the process? It should stay running until your development is finished and you are ready to build your assets for production.

If you keep the process running but still face the issue, you can try to update Herd, install a fresh project and see if everything works.

lukgol26's avatar

i have the same problem with herd / laravel12 / inertia / react app / windows11 no matter what changes i did it is not shown in brower. anyone has clue how to fix this issue?

Please or to participate in this conversation.