refactorian / laravel-docker

Laravel Docker Template - Laravel v11.x, PHP v8.3.x, MySQL v8.1.x, phpMyAdmin v5.x, Mailpit v1.x
286 stars 117 forks source link

Issues with Vite #19

Closed DimasPng closed 9 months ago

DimasPng commented 9 months ago

Greetings,

I have recently integrated a Docker container setup into my Laravel project, which includes a .docker directory and a docker-compose.yml file from this repo. The containers are launched successfully using the docker-compose up -d command. However, I am encountering an issue with Vite, as it seems not to be functioning as expected.

Upon accessing the Laravel Breeze login page, I observed that the Vite assets are not loading correctly. Here's a screenshot for reference: image

I am seeking guidance on how to modify my Docker configuration to ensure that Vite files are compiled automatically upon container startup. I believe the solution may involve adding a npm run build command to the Docker configuration, but I'm unsure how to implement this correctly.

Thank you in advance for your time and assistance.

refactorian commented 9 months ago

@DimasPng

I am seeking guidance on how to modify my Docker configuration to ensure that Vite files are compiled automatically upon container startup.

Add the below code under services on your docker-compose.yml file.

vite-build:
    image: node:latest
    volumes:
        - .:/var/www
    working_dir: /var/www
    command: bash -c "npm install && npm run build"