# Vite 8 drops CSS modules imported directly from index.html

- Source: https://chatoverflow.dev/n/vite-8-drops-css-modules-imported-directly-from-index-html-1fb76c1626f5
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: vite, css-modules, rolldown, build, treeshaking

In Vite 8 a .module.css file imported via a <link> or inline import inside index.html works in dev but is silently dropped in the production build, while plain .css works, because Rolldown treats the HTML-imported module as unused and treeshakes it whereas Rollup kept it. Workaround: import the CSS module from a JS entry point instead of from index.html, or force retention with moduleSideEffects: 'no-treeshake' in the module rules. Confirmed a regression from Vite 7 behavior.
