Vite
Vite serves source as native ES modules in development and ships a Rolldown bundle with Oxc transforms in production. Interviewers ask because the gap left between the two explains most surprises.
on this pageshowhide
explore
- Dev Server & HMR6 questions
- Dependency Pre-Bundling6 questions
- Configuration6 questions
- Plugin System6 questions
- Production Bundling6 questions
- Env Vars & Assets6 questions
questions
page 2 of 2After a Vite config sets `css.transformer: 'lightningcss'`, why do postcss.config.js plugins and `css.modules` naming options silently stop applying?
basics
~20 scss.transformer picks the engine for CSS processing. With 'lightningcss', Vite hands each stylesheet to Lightning CSS instead of PostCSS, so PostCSS config and plugins never run, and CSS Modules naming moves to css.lightningcss.cssModules; css.modules feeds postcss-modules only.
In Vite 8.1 and later, a dev server reached through an HTTPS reverse proxy serves pages but never hot-updates; how does server.ws fix the HMR socket?
basics
~20 sVite's HMR client opens a WebSocket to the page's own host and port, so a proxy that does not forward WebSocket upgrades breaks it. Proxy WebSockets too, or set server.ws options such as clientPort, which Vite 8.1 moved from server.hmr.
With Vite 8.1 or later, how do `import { plan } from './planner.wasm'` and `./planner.wasm?init` differ, and when do you need `?url` instead?
basics
~20 sSince Vite 8.1 a direct .wasm import is instantiated by Vite and exposes the module's exports as named ES exports. ?init returns a function that instantiates on demand with your imports. Use ?url when you need the WebAssembly.Module itself.
When porting an in-house Rollup-style plugin to Vite 8, why add hook filters, when should load or transform return moduleType: 'js', and which Rollup hooks stop running?
basics
~20 sIn Vite 8, Rolldown calls JavaScript plugins from Rust, so hook filters let it skip unrelated modules. A load or transform turning another type into JavaScript should return moduleType: 'js'. shouldTransformCachedModule, resolveImportMeta and renderDynamicImport no longer run.
After upgrading to Vite 8, `import Recur from 'recur-rules'` (a CommonJS package compiled from ESM) in an app with `"type": "module"` yields an object holding `default`, not the function; why, and what fixes it?
basics
~20 sVite 8 makes the default import of a CommonJS module equal module.exports whenever the importer is .mjs or .mts or its package.json declares type: module, even if the module sets __esModule. Read .default explicitly, or get the package fixed.
In Vite, how does an SSR build made with `vite build --ssr` differ from the client build, and when do you add a dependency to `ssr.noExternal`?
basics
~20 svite build --ssr builds a server entry that Node loads with import(): dependencies stay external, output is unminified, and assets are left to the client build. Add a dependency to ssr.noExternal when Node cannot import it as published, so Vite must bundle it.
showing 31–36 of 36