Interview questions
Webpack, Vite and frontend tooling interview questions
Tooling questions check whether you understand what happens between your source files and what the browser downloads: bundling, transforms, splitting, caching and build speed. They come up in frontend, platform and senior interviews.
For live interviews: the FlexQ interview copilot for Mac or Windows, 30 free live minutes.
Updated 2026-11-23 · 20 questions · junior, mid-level, senior and a hands-on round · a model answer and what the interviewer is checking for each
The webpack answers refer to webpack 5 and the Vite answers to current Vite. Configuration options change between major versions, so say which version you have used when you answer.
Jump to: Junior · Mid-level · Senior · Hands-on round · How to practice · FAQ
Junior tooling questions
Junior questions check that you know why the tools exist and can read a project's setup.
1. What does a bundler do, and why do we still use one with native ES modules?
Model answer: A bundler starts from an entry file, follows every import to build a dependency graph, runs transforms such as TypeScript, JSX and CSS processing, and writes optimized output files. Browsers can load ES modules natively, but an app with hundreds of modules would load them as a waterfall of requests, discovered one level at a time. Bundling also gives minification, tree shaking, code splitting and hashed filenames for caching. Vite skips bundling your own code in development but still bundles for production.
What the interviewer is checking: That you know what the build step is for, not only how to run it.
2. What is the difference between dependencies and devDependencies, and what does the lockfile do?
Model answer: dependencies are packages the code needs at runtime; devDependencies are tools needed to build and test, such as the bundler, linters and test runners. For a frontend app that ships a bundle, the split matters less than for a published library, where consumers install only dependencies. The lockfile (package-lock.json, pnpm-lock.yaml or yarn.lock) records the exact resolved version of every package, so every machine and CI run installs the same tree. In CI, install with npm ci so the lockfile is followed exactly.
What the interviewer is checking: Reproducible installs, which is where "works on my machine" bugs start.
3. What do ^1.2.3 and ~1.2.3 mean in package.json?
Model answer: These are semver ranges. ^1.2.3 allows any version from 1.2.3 up to, but not including, 2.0.0: new minor and patch releases. ~1.2.3 allows patch releases only, up to but not including 1.3.0. For versions below 1.0.0 the caret is stricter: ^0.2.3 means up to but not including 0.3.0, because in 0.x a minor bump may break things. The lockfile pins what was actually installed.
What the interviewer is checking: Precise version semantics, including the 0.x exception.
4. What is a source map?
Model answer: A source map is a file that maps positions in the generated, minified code back to the original source files and lines. Browser DevTools and error-reporting services use it to show readable stack traces and let you set breakpoints in your own code. In development, faster but less precise source map types are common; in production, many teams generate full maps and upload them to their error tracker instead of serving them publicly.
What the interviewer is checking: Whether you have debugged production code and know the trade-off of exposing maps.
5. What is the difference between ESLint and Prettier?
Model answer: ESLint is a linter: it analyzes code for likely bugs and agreed patterns, such as unused variables, missing hook dependencies or unsafe comparisons, and some rules can fix code automatically. Prettier is a formatter: it reprints code in one consistent style and has almost no options on purpose. Teams usually run both, with eslint-config-prettier turning off ESLint's formatting rules so the two do not fight. Running them in CI and in a pre-commit hook keeps reviews about logic rather than style.
What the interviewer is checking: Knowing the separate jobs and a sensible setup.
Mid-level webpack and Vite questions
Mid-level questions go into configuration: what each piece does and what you would change.
6. Explain the core webpack concepts: entry, output, loaders, plugins and mode.
Model answer: The entry is where webpack starts building the dependency graph. The output says where to write the bundles and how to name them; [contenthash] in the filename changes only when the content does. Loaders transform individual files so webpack can handle them, for example TypeScript or CSS, and in a use array they run from last to first. Plugins hook into the whole compilation, for example to generate the HTML file. mode: 'production' turns on minification and other optimizations.
// webpack.config.js
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'production',
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[contenthash].js',
clean: true,
},
module: {
rules: [
// css-loader runs first, then style-loader
{ test: /\.css$/i, use: ['style-loader', 'css-loader'] },
],
},
plugins: [new HtmlWebpackPlugin()],
};
What the interviewer is checking: Whether you can read and change a real config without copying from a blog.
7. What is the difference between a webpack loader and a plugin?
Model answer: A loader works on one module at a time: it takes the source of a file that matches a rule and returns transformed source, such as JavaScript from TypeScript. A plugin taps into hooks of the compiler and the compilation, so it can do things that span the whole build: generate files, change how chunks are split, inject environment variables, or report on the output. If the task is "turn this kind of file into JavaScript", it is a loader; anything else is usually a plugin.
What the interviewer is checking: A clear mental model of webpack's architecture.
8. How does tree shaking work, and what stops it from working?
Model answer: Because ES module import and export are static, the bundler can see which exports are never used. In production mode webpack marks those exports and the minifier removes the dead code; Rollup-based tools drop it while bundling. It stops working with CommonJS modules, whose exports are dynamic, and with code that has side effects at import time. The sideEffects field in a package's package.json tells the bundler which files are safe to drop entirely.
What the interviewer is checking: Why bundles stay large even after "we turned on tree shaking".
9. What is code splitting, and how do you decide where to split?
Model answer: Code splitting breaks the bundle into chunks that load on demand, so the first page downloads only what it needs. A dynamic import() creates a split point; in React, React.lazy with Suspense wraps it for components. Route boundaries are the usual first split, then heavy features that few users open, such as an editor or charts. Shared vendor code goes into its own chunk so it stays cached across deploys; too many tiny chunks cost extra requests.
What the interviewer is checking: Judgment about where splitting pays off.
10. Why is Vite fast in development, and how is its production build different?
Model answer: In development Vite does not bundle your source: it serves files as native ES modules and transforms each one on request, so start-up does not grow with the size of the app. Dependencies are pre-bundled once (with esbuild up to Vite 7, with Rolldown from Vite 8), because packages with hundreds of internal modules would be slow to load one by one. Production is a real bundle: Rollup up to Vite 7, and Rolldown, a Rust bundler with a Rollup-compatible plugin API, from Vite 8. Because the two paths differ, always test the production build, not only the dev server.
What the interviewer is checking: That you know the dev/prod difference and its risk.
11. How does hot module replacement (HMR) work?
Model answer: The dev server watches files and, when one changes, sends a message over a WebSocket to the page. The client runtime fetches the new version of that module and replaces it without reloading the page, then walks up the import chain to the nearest module that accepts the update; if none does, it falls back to a full reload. Framework integrations such as React Fast Refresh accept updates for components and keep their state. Changes to code outside components often reload the page for that reason.
What the interviewer is checking: Understanding of the tool you use all day, useful when HMR breaks.
12. How do hashed filenames help with caching?
Model answer: If a file's name contains a hash of its content, such as main.3f9a1c.js, the name changes exactly when the content does. Those files can be cached by browsers and CDNs for a long time with Cache-Control: max-age=31536000, immutable, because a new deploy produces new names. The HTML that references them must not be cached long, or users keep loading old file names. Keeping vendor code in a separate chunk means a deploy that only changes app code leaves the vendor file cached.
What the interviewer is checking: Caching strategy that connects the build to production.
13. What is the difference between transpiling and polyfilling, and where does browserslist fit in?
Model answer: Transpiling rewrites new syntax into older syntax, for example optional chaining into explicit checks; Babel, SWC and esbuild do this. Polyfilling adds missing built-in APIs at runtime, for example Array.prototype.at, usually from core-js. A transpiler can not add a missing API, and a polyfill can not add new syntax. Browserslist is the shared list of target browsers that tools such as Babel's preset-env and Autoprefixer read to decide what to transform.
What the interviewer is checking: Precision about two often-confused ideas.
Senior tooling questions
Senior questions are about build speed, bundle size and the build setup of many teams at once.
14. A webpack build has become slow. How would you speed it up?
Model answer: First measure where the time goes, with webpack --profile --json and a stats analyzer, or a plugin that times each loader. Common fixes: enable the persistent cache with cache: { type: 'filesystem' } in webpack 5, replace babel-loader with swc-loader or esbuild-loader, limit loaders to your own source with include, use a cheaper source map type in development, and move type checking to a separate process. If the config is mostly standard, Rspack offers a largely webpack-compatible API with a Rust core.
What the interviewer is checking: A measured approach and current knowledge of faster tools.
15. How do you analyze and reduce bundle size?
Model answer: Look at what is actually in the bundle with webpack-bundle-analyzer, rollup-plugin-visualizer or source-map-explorer. The usual wins are replacing heavy libraries with smaller ones or native APIs, importing only what you use, lazy-loading routes and rarely used features, and removing duplicate copies of a dependency at different versions. Then lock the result in with a size budget checked in CI, so it does not grow back release by release.
What the interviewer is checking: Method plus a way to keep the gain.
16. What is Module Federation, and when is it worth the complexity?
Model answer: Module Federation, introduced in webpack 5, lets separately built and deployed applications load code from each other at runtime and share dependencies such as React as a single copy. It is one way to build micro-frontends, where several teams deploy parts of one product independently. The cost is real: version coordination for shared dependencies, failures that appear only at runtime, and harder local development and testing. It is worth it when independent deploys for separate teams matter more than those costs, not as a default.
What the interviewer is checking: Architectural judgment about a powerful but expensive tool.
17. How would you migrate a project from webpack to Vite?
Model answer: List what the webpack config does: loaders, plugins, aliases, environment variables, proxy settings. Then map each item: index.html moves to the project root as the entry, process.env.X becomes import.meta.env.VITE_X, require() calls become imports, and aliases move to resolve.alias. Old CommonJS-only dependencies and custom loaders are the usual blockers. Migrate on a branch, compare the production bundle and run the end-to-end tests before switching.
What the interviewer is checking: Practical migration planning and awareness of the common blockers.
18. How do you set up builds in a monorepo with many packages?
Model answer: Use the package manager's workspaces (npm, Yarn or pnpm) so packages link to each other locally. A task runner such as Turborepo or Nx understands the dependency graph between packages, runs tasks in the right order and in parallel, and caches results, locally and in CI, so unchanged packages are not rebuilt. In CI, build and test only the packages affected by a change. Agree on shared configs for TypeScript, ESLint and the bundler so packages do not drift.
What the interviewer is checking: Experience with build systems at team scale.
Hands-on tooling round
Hands-on tooling tasks are small: write a loader or a plugin, or fix a config while explaining what each line does.
19. Write a webpack loader that imports .txt files as strings.
Model answer: A loader is a function that receives a file's source and returns JavaScript. This one returns a module whose default export is the text; JSON.stringify escapes quotes and newlines safely. Register it in module.rules with test: /\.txt$/. Then mention that webpack 5 does this without a custom loader: type: 'asset/source' on the rule.
// text-loader.js
module.exports = function textLoader(source) {
return `export default ${JSON.stringify(source)};`;
};
// webpack.config.js, inside module.rules:
// { test: /\.txt$/, use: path.resolve(__dirname, 'text-loader.js') }
What the interviewer is checking: That loaders are simple functions, and that you know the built-in option.
20. Write a Vite plugin that provides a virtual module with the build time.
Model answer: A Vite plugin is an object with hooks, most of them shared with Rollup. resolveId claims the virtual import, and by convention the resolved ID starts with \0 so other plugins leave it alone. load returns the module's source. Application code can then import { builtAt } from 'virtual:build-info'.
// vite.config.js
import { defineConfig } from 'vite';
function buildInfo() {
const id = 'virtual:build-info';
const resolvedId = '\0' + id;
return {
name: 'build-info',
resolveId(source) {
if (source === id) return resolvedId;
},
load(moduleId) {
if (moduleId === resolvedId) {
return `export const builtAt = ${JSON.stringify(new Date().toISOString())};`;
}
},
};
}
export default defineConfig({ plugins: [buildInfo()] });
What the interviewer is checking: Knowing the plugin hooks well enough to extend the build.
How to practice
Take a project you know, delete its build config and rebuild a minimal one from memory, then run a bundle analyzer on it and explain the three biggest chunks out loud. Rehearse out loud with the free voice mock interviewer at interview.flexq.app: paste the job description, add your résumé if you like, and answer by voice (typing works too). It follows up where an answer is thin and ends with a scored report that quotes your answers back. Three mock interviews are free with an email sign-up, no card.
During the real interview, the FlexQ interview copilot can show short cues on the interviewer's questions, grounded in your résumé and the job post, and you answer in your own words. Follow the rules of the company you're interviewing with.
Practice a free mock interview
Paste a frontend or platform job description and the mock interviewer asks questions like these and follows up on how you have used the tools. Three mock interviews are free with an email sign-up, no card.
For live interviews: the FlexQ interview copilot for Mac or Windows, 30 free live minutes.
On the real call
FlexQ also has a live copilot for macOS and Windows. Add your résumé and the job description, and when a question like these lands it shows a short cue from your own experience, so you answer in your own words. Your first 30 live minutes are free. Get FlexQ.
FAQ
Do frontend interviews still ask about webpack?
Yes, many existing codebases run on webpack, so interviews ask about loaders, plugins, splitting and build speed. Newer projects often use Vite, and knowing why it is fast is a common follow-up.
Should I learn webpack or Vite for interviews?
Know the concepts they share (bundling, transforms, splitting, caching), webpack's loader and plugin model, and how Vite's dev server differs. That covers most questions whichever tool the team uses.
Who gets tooling questions?
Most frontend developers get a few. Senior, platform and developer-experience roles get many more, including build speed, monorepos and migrations.
What is the most common tooling question?
Some form of "how would you make this bundle smaller or this build faster". Answer with a measurement first, then the two or three changes with the biggest effect.
How do I prepare for tooling questions without a big project?
Create a small app, configure webpack by hand, then migrate it to Vite and compare. Run a bundle analyzer, add a lazy route and watch the chunks change.
Related
Frontend topics: React · JavaScript · TypeScript · Frontend system design · Frontend developer
More: Software engineer questions · System design interview questions · "Tell me about yourself" · Practice out loud · All interview questions