I want to use Vite together with my Laravel 9 application. I am using https://github.com/laravel/vite-plugin to connect them.
My folder structure is like this:
/resources
/vite
/package.json
/vite.config.js
/app.js
/node_modules
Usually Vite is in the root directory. However, I want to have Laravel mix for now in the root directory and vite in a subdirectoy. I want to slowly migrate from laravel.mix / Vue2 to Vite/Vue3 and rebuild my entire dashboard, so this is more convinient for me.
The command
npm run build
works fine. However,
npm run dev
is not working. The problem is, that the "hot" file is not generated in the /public directory.
This is my standard setup:
laravel( {
input: [
// 'resources/css/app.css',
'./app.js',
]
}),
With this configuration, vite tries to generate the hot file in "/resources/vite/public/hot". When I try to adjust the path like this:
laravel( {
input: [
// 'resources/css/app.css',
'./app.js',
],
publicDirectory: '../../public',
}),
I get this error:
node:internal/fs/utils:346 throw err; ^
Error: EISDIR: illegal operation on a directory, open '../../public/hot' at Object.openSync (node:fs:584:3) at Object.writeFileSync (node:fs:2201:35) at Server. (/home/adam/www/personal-projects/memberportal/resources/vite/node_modules/laravel-vite-plugin/dist/index.cjs:135:29) at Object.onceWrapper (node:events:627:28) at Server.emit (node:events:525:35) at emitListeningNT (node:net:1775:10) at process.processTicksAndRejections (node:internal/process/task_queues:81:21) { errno: -21, syscall: 'open', code: 'EISDIR', path: '../../public/hot' }
Node.js v19.4.0
How to change the path?