Skip to content

HMR feature does not work with Laravel #57

@mansoorkhan96

Description

@mansoorkhan96

I have tried in many different ways but the HMR would not work in Laravel.

error in console: net::ERR_ABORTED 404 (Not Found)

I have added following in vite.js

import { defineConfig } from 'vite';
import laravel, { refreshPaths } from 'laravel-vite-plugin';
import VitePluginSvgSpritemap from '@spiriit/vite-plugin-svg-spritemap';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/css/app.css',
                'resources/js/app.js',
            ],
            refresh: false,
        })
        VitePluginSvgSpritemap('resources/svg/*.svg', {
            injectSVGOnDev: true,
        }),
    ]
});

And in my blade layout where i add app.js.

 @vite([
    'resources/js/app.js',
    '@vite-plugin-svg-spritemap/client',
])

Svg blade component

@props(['name'])

<svg {{ $attributes->merge(['class' => 'icon']) }}>
    <use href="#sprite-{{ $name }}"></use>
    {{-- Production --}}
    {{-- <use href="{{ Vite::asset('spritemap.svg') }}#sprite-{{ $name }}"></use> --}}
</svg>

Screenshots

It seems to generate the HMR script url but does not inject the svg sprites.

image image

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions