alex32's avatar
Level 2

Auto-Update docker container after changes | Vite

I'm developing locally with Docker and I'd like my changes to be reflected in the container, without re-building it manually every time. I've added refresh: true in vite.config but it doesn't work. There must be a way to do that. Thanks

  • Laravel 11 | Vite, Breeze-React
  • Docker Desktop 4.38 | Win 10
  • WSL Ubuntu 22.04
  • VS Code | Ubuntu workspace : \wsl.localhost\Ubuntu\home\myProject

How I build the container after changes:


$ sail npm run build -dev

docker-compose.yml

vite.config.js


import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import react from '@vitejs/plugin-react';
import purge from '@erbelion/vite-plugin-laravel-purgecss'

export default defineConfig({
    plugins: [
        laravel({
            input: 'resources/js/app.jsx',
            refresh: true,
        }),
        react(), 
        purge({
            paths: ['resources/{js,views}/**/*.{blade.php,react,jsx,js,css}']
 
        })
    ],
});



package.json

0 likes
2 replies
alex32's avatar
Level 2

@RemiM Thanks,

  • The 1st link is 2yrs old and not very relevant , though eventually they got a similar (unresolved) problem.
  • The 2nd link , you're amazing! it worked. Changes are reflected without even reloading the page. I updated vite.config.js and adjusted the following commands for my environment:

From WSL terminal, with Docker Desktop running:

$ sail up  --build -d     | build the containers
$ sail npm run dev     | dropped   exec -it app

Where sail is my alias defined as below:

$ echo "alias sail='./vendor/bin/sail' " >> ~/.bashrc 

Please or to participate in this conversation.