I’m working on a SvelteKit project and recently added Tailwind CSS following the official documentation. Everything runs perfectly when I use npm run dev locally, but I get a module not found error when trying to run the same project through Docker.
The error happens when I execute docker compose up from my main project directory. Before adding Tailwind, the Docker setup worked without issues. The problem started after I modified my Vite configuration file to include Tailwind support.
Here’s my current Vite setup:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
import tailwindPlugin from '@tailwindcss/vite';
export default defineConfig({
plugins: [
tailwindPlugin(),
sveltekit(),
],
server: {
host: true,
},
});
I suspect there might be a path resolution issue in the Docker environment or maybe some dependencies are missing in the container. Has anyone faced similar issues when dockerizing SvelteKit projects with Tailwind CSS?
Probly a working dir issue with Docker. Check if your WORKDIR matches where Vite expects the config file. Docker sometimes changes context and can’t find vite.config.js even tho it’s there locally.
Sounds like a Node version mismatch between your local setup and Docker. I had the same issue - local was running 18.x while Docker used 16.x. The Tailwind Vite plugin acts weird when versions don’t match. Check your Dockerfile uses the exact Node version you’re running locally. Also make sure package-lock.json copies into the container correctly. Once I matched the Node versions, all the Vite config path issues vanished. The @tailwindcss/vite plugin really doesn’t like version differences.
Check your Dockerfile - you’re probably not copying all the files before npm install runs. The @tailwindcss/vite plugin needs specific dependencies that aren’t getting installed properly in your container. I’ve hit this exact same issue when the plugin couldn’t find files that weren’t in the Docker context. Add a step to verify vite.config.js exists in your working directory after copying. Also check if your .dockerignore is blocking config files that Tailwind needs. The plugin often fails silently in Docker when files are missing from the build context.
Docker’s handling node_modules differently than your local setup. When you added the Tailwind Vite plugin, Docker can’t resolve those dependencies properly during build. I hit this exact issue last month with the same stack. Fix is tweaking your Docker build order - copy package.json first, run npm install, then copy everything else. This way Docker actually installs @tailwindcss/vite plugin before it needs it. Your vite.config.js looks fine, so it’s definitely the Dockerfile layer order. Don’t copy vite.config.js before installing dependencies - Vite will try parsing the config during startup and the Tailwind plugin won’t exist yet.
Docker build issues like this are exactly why I automated our entire deployment pipeline. Tailwind + Vite creates dependency hell in containers.
Your container’s probably missing environment variables or file permissions that work locally. Docker runs with different user contexts and path resolvers than your local npm.
Instead of debugging Docker configs and endless rebuilds, I’d set up automation. Create workflows that handle the entire build process, manage dependencies correctly, and deploy without these container headaches.
I’ve seen teams waste weeks on Docker + Vite issues. Smart move is automating everything so you never touch Docker configs again. Set up build automation that handles SvelteKit, Tailwind, and deployment in one flow.
This eliminates container environment differences completely. No more wondering if files copied right or dependencies match.
Latenode makes this easy to set up. You can automate the entire build and deploy process without dealing with Docker quirks: https://latenode.com
i had a similar prob! make sure the paths in vite.config.js are correct, sometimes using absolute paths helps. also, don’t forget to rebuild your docker image, caching can cause issues.