Closed haosmos closed 1 year ago
in the Laravel community in discord, a person under the nickname @Mono2000 helped me, for which I express my deep gratitude to him!
the problem was that in the vite.config.js file, I placed the block with plugins in the code block with server settings - like this:
but it was necessary to move this code block to the same level as the server settings code block - that is, it was necessary to do this:
thank you so much @Mono2000!
Version:
@inertiajs/vue3
version: 1.0.9Describe the problem:
application in conjunction: laravel + vue.js + inertia.js does not work in docker
Steps to reproduce:
Problem: I can't setup laravel + vue.js + inertia.js app in docker.
What I did:
cloned repo with laravel:
git clone https://github.com/laravel/laravel.git
created the
docker-compose.yaml
file:according to my idea, the data in the node container (the node_modules folder and the package.json and package-lock.json files) should be synchronized with the project on the host via volume:
nginx
:created the application image:
docker compose build
installed dependencies for laravel:
composer install
- including packageinertiajs/inertia-laravel
php artisan key:generate
php artisan migrate
installed npm dependencies in vue container:
vite.config.js file
:/resources/views/welcome.blade.php
file toapp.blade.php
and addedvite
andinertia.js
directives:\App\Http\Middleware\HandleInertiaRequests::class
in the web middleware group in/app/Http/Kernel.php
-resources/js/app.js
specified settings forinertia.js
:resources/js/Pages
:Http/Controllers/IndexController.php
controller that handles/
and/hello
routes usinginertia.js
when launching containers and in a browser at
localhost:8000
, where, in theory, the application should open, the following error is displayed:with node container running:
but if you go to this address - http://localhost:5173, you will get an error:
if you run the
npm run build
command in the node container (where node.js and all npm dependencies are installed), you will get this error:with all dependencies installed in the container
all dependencies are also present on the host machine:
question: where is the error and how to configure the application (docker? vite.config.js config? laravel?) so that everything works? i.e.
my goal is to work with laravel + vue.js using inertia.js
my repository: https://github.com/haosmos/lara-vue-inertia
my work environment:
WSL2: 1.3.14.0 NODE.JS: 18 LARAVEL: 10.16 VUE.JS: 3.3.4 VITE: 4.4.7
inertiajs/inertia-laravel: 0.6.9, laravel-vite-plugin: 0.7.5, @vitejs/plugin-vue: 4.2.3, vue: 3.3.4, @inertiajs/vue3: 1.0.9