All questions
Showing of 89How does Vite achieve faster development server startup compared to traditional bundlers?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Vite starts fast because it does not bundle your app before serving it. A bundler such as webpack builds the whole application first, so the larger the app, the longer the wait.
Vite splits the work in two:
- Dependencies from
node_modulesrarely change. Vite pre-bundles them once with Rolldown, a fast bundler written in Rust. Each package becomes a single module, cached until the lockfile changes. - Source code is served as native ES modules. The browser requests each file through
importstatements, and Vite compiles a file only when the browser asks for it.
So the dev server starts almost instantly, even for large applications. Hot Module Replacement (HMR) stays fast for the same reason: an edit updates just that module, with no rebuild. The trade-off is request count, since a very large codebase can load pages slowly in development.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is Hot Module Replacement (HMR) and how does it work in Vite?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Hot Module Replacement (HMR) swaps an edited module into the running page without a full page refresh, so application state survives the edit.
Vite's dev server detects file changes on its own and pushes each update to the browser over a WebSocket. The browser re-imports the changed module, plus any importers up to the nearest module that accepts the update. Because Vite serves native ES modules, an edit needs no bundle rebuild, so updates are nearly instant and much faster than with traditional bundlers.
Vue, React and Svelte hook into this through Vite's HMR API, import.meta.hot, to keep state across updates.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you create a new Vite project?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Run npm create vite@latest and answer the prompts for a project name, a framework and a variant. The command runs create-vite, a tool that scaffolds a starter project from a template. Yarn and pnpm have the same command:
# Using npm
npm create vite@latest my-project
# Using yarn
yarn create vite my-project
# Using pnpm
pnpm create vite my-project
Vite provides templates for these frameworks:
vanilla,vanilla-tsvue,vue-tsreact,react-ts,react-compiler,react-compiler-tspreact,preact-tslit,lit-tssvelte,svelte-tssolid,solid-tsqwik,qwik-ts
To skip the prompts, name the template directly. With npm 7 and later, an extra -- goes before the options:
npm create vite@latest my-react-app -- --template react-ts
Then run npm install and npm run dev inside the new folder. Current Vite needs Node.js 20.19 or later, or 22.12 or later.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the basic file structure of a Vite project?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A Vite project keeps index.html in the project root, the source code in src, and static files in public. The Vite configuration, vite.config.js, sits in the root next to package.json.
my-vite-app/
├── public/ # Static assets served directly
│ └── favicon.ico
├── src/ # Source code
│ ├── assets/ # Assets processed by Vite
│ ├── components/ # Components
│ ├── main.js # Application entry point
│ └── style.css # Styles
├── index.html # HTML entry point (in root!)
├── package.json
└── vite.config.js # Vite configuration
Two things differ from other bundlers. index.html lives in the root, not in a public folder, because it is the entry point Vite serves. And Vite processes the source files in src, while it serves the files in public directly and copies them to the build output unchanged.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What's the difference between the public directory and the src/assets directory in Vite?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Vite copies files in public to the build untouched, but it runs files in src/assets through its build pipeline when your code imports them.
public: Vite serves these files at the root path, so you reference them with absolute paths such as/favicon.ico. Vite does not process them, and they keep their original names in production. Use it for favicons,robots.txtand manifest files.src/assets: you import these files in JavaScript or CSS. Each gets a hashed file name, plugins can process it, and only the files your code references reach the build. Use it for images, fonts and component CSS.
// src/assets - processed and hashed
import logo from './assets/logo.png'
// public - served directly
// Reference as '/logo.png' in HTML
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you run a Vite development server and build for production?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Run npm run dev to start the development server and npm run build to create the production build. The scaffolded package.json maps these scripts to the vite and vite build commands, which you can also run directly with npx.
Start the development server:
npm run dev
# or
npx vite
Build for production:
npm run build
# or
npx vite build
Preview the production build locally:
npm run preview
# or
npx vite preview
The development server runs on http://localhost:5173 by default. It provides Hot Module Replacement, an error overlay and source maps, and with the React plugin, edits apply through React Fast Refresh.
The production build writes optimized, minified bundles to the dist directory. vite preview serves that folder at http://localhost:4173 so you can test it, but it is not a production server.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the role of index.html in a Vite project?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
index.html is the entry point of a Vite application. Vite treats it as source code and part of the module graph, the map of which files import which. That is why it lives in the project root, not in a public folder.
Vite uses index.html like this:
- It is the page the dev server starts from.
- Its
<script type="module">tag tells Vite where your JavaScript starts. - Vite processes the HTML and injects the assets it needs.
- In development, Vite serves the file directly.
- During
vite build, Vite injects the CSS links and updates the script paths.
<!DOCTYPE html>
<html>
<head>
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the core concepts of Webpack
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Webpack builds a dependency graph from an entry point and emits it as output bundles, with loaders and plugins shaping the work in between. It is a static module bundler, which follows every import and require from the entry and combines the modules into bundles. The four main concepts:
entryis the module where webpack starts building the dependency graph,./src/index.jsby default.outputsets where and how to emit the bundles,./dist/main.jsby default.- Loaders, set in
module.rules, transform files from other languages and formats, such as CSS or TypeScript, into modules. pluginsextend webpack for wider tasks such as bundle optimization, asset management and injecting environment variables.
The docs list two more core concepts. mode turns on built-in defaults for development or production. The other is browser compatibility. The code webpack generates uses Promise for import(), so older browsers need a polyfill.
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [{ test: /\.js$/, use: 'babel-loader' }]
},
plugins: [new HtmlWebpackPlugin()]
};
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the basic structure of a Webpack configuration file
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A webpack.config.js file is a Node.js module that exports one configuration object. Webpack uses it automatically when it sits in the project root, and the --config flag points to another file. Each top-level key controls one part of the build:
const path = require('path');
module.exports = {
mode: 'development', // or 'production'
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
// Loader configurations
]
},
plugins: [
// Plugin instances
],
devServer: {
// Dev server configuration
}
};
modeturns on webpack's built-in defaults for development or production.entryis the module where webpack starts building the dependency graph.outputsets the folder and file name of the bundles. The folder must be an absolute path, which is why the config callspath.resolve.module.ruleslists the loaders that transform files such as CSS or TypeScript.pluginsholds plugin instances that work on the whole build.devServerconfigureswebpack-dev-serverfor local development.
The file can also export a function that receives the CLI's env and argv, so one file can return a different config per environment.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are loaders and how do they work?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A loader transforms a file from another language or format into a module webpack can bundle. That is how an import can pull in CSS, TypeScript or modern JavaScript that older browsers cannot run.
Loaders run during the build, one file at a time. When a file matches a rule's test in module.rules, webpack runs that rule's loaders on its source. The exclude option skips paths such as node_modules.
module.exports = {
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
}
};
Here babel-loader compiles modern JavaScript with the @babel/preset-env preset passed in its options. Loaders in a use array run right to left, or bottom to top, and each receives the previous loader's output. So css-loader reads the CSS first, then style-loader injects it into the page.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the difference between style-loader and css-loader
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
css-loader turns a CSS file into a JavaScript module, and style-loader puts that CSS on the page. In the classic setup, the two work together so that import './styles.css' styles the page.
css-loaderinterprets@importandurl()the way webpack treatsimportandrequire(). It resolves those CSS dependencies and returns the CSS as a string.style-loaderinjects that CSS into the DOM by adding<style>tags when the bundle runs.
Loaders run right to left, so style-loader sits first in the array and runs after css-loader.
// This processes CSS files and injects them into the DOM
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
For production, MiniCssExtractPlugin.loader has long replaced style-loader, so the CSS goes into separate .css files the browser can cache. Since webpack 5.109, built-in CSS support is on by default for .css files that no loader rule matches. It can extract or inject styles itself, and mini-css-extract-plugin is now deprecated.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are webpack plugins and how do they differ from loaders?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A webpack plugin works on the whole compilation, while a loader transforms one file at a time.
Loaders work at the file level. They process each matching file before its module is added to the bundle. Plugins work at the bundle level. They hook into the build process, so they can change it, add files to the output or optimize the result.
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
})
]
};
You add a plugin by creating an instance with new in the plugins array. Here HtmlWebpackPlugin builds an HTML file from a template and adds the bundles to it.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is HtmlWebpackPlugin and why is it useful?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
HtmlWebpackPlugin generates the HTML file that loads your webpack bundles, so you never maintain the <script> and <link> tags by hand.
- It adds a tag for every bundle automatically.
- When file names carry a content hash for cache busting, the plugin writes the new names on every build.
- It can start from your own HTML template with variables.
- One plugin instance per page builds a multi-page app.
new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'index.html',
chunks: ['app'], // Only include specific chunks
minify: process.env.NODE_ENV === 'production'
})
Here chunks limits the page to the app bundle, and minify turns HTML minification on for production builds.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you configure webpack-dev-server?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
You configure webpack-dev-server in the devServer key of webpack.config.js and start it with npx webpack serve. It serves your app during development and rebuilds as you save.
module.exports = {
devServer: {
static: './dist',
port: 3000,
open: true,
hot: true,
compress: true,
historyApiFallback: true, // For SPA routing
proxy: [
{
context: ['/api'],
target: 'http://localhost:8080',
changeOrigin: true
}
]
}
};
staticserves files from a folder,publicby default.hotturns on Hot Module Replacement, which is already the default.compressenables gzip.openopens the browser after the server starts.historyApiFallbackservesindex.htmlin place of 404 responses, which client-side routing needs.proxyforwards API requests such as/apito another server. Since webpack-dev-server 5, it takes an array of objects with acontextlist.
changeOrigin rewrites the Host header to match the target, because the original header is kept by default.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the difference between transpilation, minification, and compression?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Transpilation changes the syntax, minification makes the code smaller without changing what it does, and compression encodes the bytes sent over the network.
| Transpilation | Minification | Compression | |
|---|---|---|---|
| What changes | The syntax, such as TypeScript or newer JavaScript turned into JavaScript older browsers run | Whitespace and comments removed, long names shortened, dead code dropped | The bytes, encoded with gzip or Brotli |
| Typical tool | Babel, TypeScript, Oxc | Terser, Oxc minifier | The web server or a content delivery network (CDN) |
| When it runs | Build time, file by file | Build time, after bundling | When the file is served, and the browser decodes it |
Transpilation is about compatibility, such as erasing TypeScript types or rewriting modern syntax for older browsers. Minification is about size, and most of its savings come from removing whitespace and shortening names, called mangling. Compression comes last. The server sends the minified file gzip or Brotli encoded, and the browser decodes it to the same text. Some builds also write pre-compressed .gz or .br files so the server does not compress on every request.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you configure Vite using vite.config.js?
What are Vite plugins and how do they work?
How does Vite handle CSS preprocessing (Sass, Less, Stylus)?
How do you handle environment variables in Vite?
How does Vite handle asset imports and processing?
What is dependency pre-bundling in Vite and why is it important?
How do you configure path aliases in Vite?
How does code splitting work in Vite?
How do you configure Vite for different environments (development, staging, production)?
What is library mode in Vite and how do you use it?
How does Vite handle TypeScript and what are the configuration options?
What are the differences between Vite and Webpack?
How do you handle dynamic imports and lazy loading in Vite?
How do you configure Vite for PWA (Progressive Web App) development?
How do you optimize Vite for production builds?
How do you handle testing in a Vite project?
How do you handle CORS and proxy configuration in Vite?
How do you configure Vite for different deployment scenarios?
What is the difference between Webpack and other bundlers like Rollup or Parcel?
How does Webpack's dependency graph work?
What are multiple entry points in webpack and when would you use them?
How do you configure webpack for development and production?
How do you handle different file types (images, fonts, etc.) in Webpack?
What is the purpose of babel-loader and how do you configure it?
Explain some commonly used Webpack plugins
How do you extract CSS into separate files in webpack?
What is code splitting and why is it important?
How do you implement dynamic imports for code splitting?
What is tree shaking and how does it work in Webpack?
How does Hot Module Replacement work in webpack?
What are source maps and how do you configure them in webpack?
How do you handle environment variables in Webpack?
What are externals in Webpack and when do you use them?
What is the difference between chunk and bundle in Webpack?
How do you handle assets and public paths in Webpack?
How do you integrate Webpack with TypeScript?
How does persistent caching work in Webpack 5?
How do you configure top-level await in Webpack 5?
What is the real content hash feature in Webpack 5?
How do you use Web Workers with Webpack 5?
Why does Vite bundle for production when it serves unbundled modules in development?
How does Vite handle CSS code splitting and what are the trade-offs?
How do you optimize bundle size in Webpack?
How do you analyze and debug Webpack bundle performance?
What are some common Webpack performance optimization techniques?
What are some common Webpack errors and how do you debug them?
What is the purpose of the optimization property in Webpack configuration?
What is Vite's Environment API and what problem does it solve?
How does Vite's plugin system work internally and how would you create a custom plugin?
How does Vite handle SSR (Server-Side Rendering) and what are the key considerations?
How do you optimize Vite build performance for large applications?
How do you configure Vite for micro-frontends architecture?
How do you implement custom transformations in Vite for specific file types?
How does Vite's development server middleware system work?
How do you handle Vite configuration for monorepos?
How do you optimize Vite for large-scale applications with thousands of modules?
How do you implement advanced bundling strategies with Vite?
How do you handle complex asset processing and optimization in Vite?
How do you debug and profile Vite build performance issues?
How do you handle security considerations in Vite?
How would you migrate a large Webpack project to Vite?
How do you implement custom hot reload logic for non-standard file types?
How do you implement advanced caching strategies with Vite?
How do you debug and troubleshoot complex Vite build issues?
Explain the SplitChunksPlugin and its configuration
What is module federation in Webpack 5?
How does module resolution work in Webpack?
How do you create a custom Webpack loader?
How do you create a custom Webpack plugin?
How do you configure Webpack 5 for microfrontends with shared dependencies?
What changed in webpack 5's Node.js API?
How do you implement advanced code splitting strategies in Webpack 5?
How do you debug and troubleshoot Webpack 5 builds effectively?
How do you migrate a project from webpack 4 to webpack 5?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Vite & Webpack in pictures.
A quick recap of Vite & Webpack in 36 short animated pictures, one idea at a time. About 9 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.
Pro The first chapter is free to play. The other 29 pictures come with Pro.
Vite & Webpack cheatsheet
- How bundlers work01
- Start a Vite project02
- Configure Vite03
- Configure webpack04
- CSS, images & fonts05
- Dev server & HMR06
- Split & lazy-load code07
- Caching, speed & debugging08
- Plugins & loaders09
- Deploy, scale & migrate10
- The model11
- + 5 more inside
This picture is part of Pro. The first chapter is free to play; the other 29 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in74 of 89 Vite & Webpack answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.