18

I'm using vite in my laravel project but when I run npm run build shows me errors in the syntax and the syntax sounds correct.

- my component enter image description here

- my vite.config.js enter image description here

- the error that I see enter image description here

larave ^9.19
vue ^3.2.30
vite ^3.0.0

how I can fix that? and thanks in advance.

5
  • Well you have a syntax error, but without code we can't say much Commented Dec 8, 2022 at 14:14
  • ok, I modified the content now Commented Dec 15, 2022 at 18:33
  • You don't call/use the vue plugin, so vue files do not work, you should add vue() in the plugins array Commented Dec 15, 2022 at 18:37
  • yes right, but when I add it I see the error in the production as I say in the first Commented Dec 15, 2022 at 18:47
  • try to import defineComponent from vue Commented Dec 15, 2022 at 19:15

1 Answer 1

61

This might be helpful for future nobs like me. I have also faced the same issue with Fresh Laravel 9 and inertia JS. I have tried all solutions and this works for me.

npm i @vitejs/plugin-vue

Open vite.config.js and write vue() function before Laravel

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue"; //add this line
import laravel from "laravel-vite-plugin";

export default defineConfig({
    plugins: [
        vue(), // write this
        laravel({
            input: ["resources/css/app.css", "resources/js/app.js"],
            refresh: true,
        }),
    ],
});

then

npm run dev

Hope it will help.

Sign up to request clarification or add additional context in comments.

6 Comments

It works. But... is this supposed to be done this way? inertiajs.com should do a better job in documentation. It is confusing for us.
I am glad it works for you. Hope inertia might update as well.
Thank you, def can be frustrating tracking this stuff down. Inertia should def try to include this in the docs.
While the error is self explanatory, (@ the time of writing) this small config is still not part of the Inertia docs in the client-side installation part
How many upvotes should these comment take, so that Inertia decide to fix their documentations??? It's been a long time this issue is not fixed!!!
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.