webpack
/webpack
Expert Webpack assistance covering asset bundling, code splitting, loaders, plugins, caching strategies, and webpack.config.js optimization. Use when configuring Webpack 5, optimizing bundle sizes, setting up Babel/TypeScript loaders, or configuring Module Federation.
- Author
- G1Joshi ↗
- Repository
- Agent-Skills ↗
- Licence
- MIT
- Last repository change
- 01.10.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 2
No signals detected. Repository changed on 01.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Expert Webpack assistance covering asset bundling, code splitting, loaders, plugins, caching strategies, and webpack.config.js optimization. Use when configuring Webpack 5, optimizing bundle sizes, setting up Babel/TypeScript loaders, or configuring Module Federation.
Original author description
Expert Webpack assistance covering asset bundling, code splitting, loaders, plugins, caching strategies, and webpack.config.js optimization. Use when configuring Webpack 5, optimizing bundle sizes, setting up Babel/TypeScript loaders, or configuring Module Federation.
How it works
- When to Use
- Quick Start
- Core Concepts
- Common Patterns
- Best Practices
- Troubleshooting
- References
SKILL.md preview
---
name: webpack
description: Expert Webpack assistance covering asset bundling, code splitting, loaders, plugins, caching strategies, and webpack.config.js optimization. Use when configuring Webpack 5, optimizing bundle sizes, setting up Babel/TypeScript loaders, or configuring Module Federation.
---
# Webpack
Webpack is the grandfather of bundlers. While slower than Vite, it offers unparalleled **flexibility** and remains the engine behind Next.js (legacy), Angular, and enterprise apps.
## When to Use
- **Enterprise Webpack 5 Bundling**: Managing complex enterprise web applications with custom asset transformations and polyfills.
- **Module Federation Micro-Frontends**: Sharing modules, components, and runtime state dynamically across distributed micro-apps.
- **Granular Code Splitting & Caching**: Fine-tuning split chunks, vendor optimization, and deterministic bundle hashing.
- **Custom Loader & Plugin Architectures**: Extending compilation pipelines with custom AST manipulation and build hooks.
## Quick Start
### 1. Minimal webpack.config.js
```javascript
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "[name].[contenthash].js",
clean: true,
},
module: {
rules: [
{ test: /\.css$/i, use: ["style-loader", "css-loader"] },
{ test: /\.(png|svg|jpg)$/i, type: "asset/resource" },
],
},
plugins: [new HtmlWebpackPlugin({ template: "./public/index.html" })],
optimization: {
splitChunks: { chunks: "all" },
},
};
```
### 2. Build via CLI
```bash
npx webpack --mode production
```
## Core Concepts
### Production Webpack 5 Configuration (`webpack.config.js`)
Configuring modern performance, caching, and splitChunks optimization:
```javascript
const path = require("node:path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const isProd = process.env.NODE_ENV === "production";
module.exports = {
mode: isProd ? "production" : "development",
entry: "./src/index.tsx",
output: {
path: path.resolve(__dirname, "dist"),
filename: isProd ? "js/[name].[contenthash:8].js" : "js/[name].js",
chunkFilename: isProd
? "js/[name].[contenthash:8].chunk.js"
: "js/[name].chunk.js",
clean: true,
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
alias: {
"@": path.resolve(__dirname, "src"),
},
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
use: {
loader: "swc-loader",
},
},
{
test: /\.css$/,
use: [
isProd ? MiniCssExtractPlugin.loader : "style-loader",
"css-loader",
"postcss-loader",
],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset",
parser: {
dataUrlCondition: { maxSize: 8 * 1024 }, // Inline under 8KB
},
},
],
},
optimization: {
minimize: isProd,
minimizer: [new TerserPlugin(), new CssMinimizerPlugin()],
splitChunks: {
chunks: "all",
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
priority: -10,
reuseExistingChunk: true,
},
},
},
},
plugins: [
...(isProd
? [
new MiniCssExtractPlugin({
filename: "css/[name].[contenthash:8].css",
}),
]
: []),
],
devServer: {
port: 3000,
hot: true,
historyApiFallback: true,
},
};
```
### Module Federation Micro-Frontend Configuration
Exposing and consuming shared components at runtime:
```javascript
const { ModuleFederationPlugin } = require("webpack").container;
module.exports = {
plugins: [
new ModuleFederationPlugin({
name: "host_app",
remotes: {
checkout: "checkout@https://cdn.example.com/checkout/remoteEntry.js",
},
shared: {
react: { singleton: true, requiredVersion: "^19.0.0" },
"react-dom": { singleton: true, requiredVersion: "^19.0.0" },
},
}),
],
};
```
### Filesystem Caching for Accelerated Builds
Enabling persistent caching to cut subsequent build times by over 80%:
```javascript
module.exports = {
cache: {
type: "filesystem",
buildDependencies: {
config: [__filename],
},
},
};
```
## Common Patterns
### Code Splitting via Dynamic Imports
**Problem**: Reduce initial page weight by deferring heavy components until needed.
**Solution**: Use ECMAScript dynamic `import()`.
```javascript
// Dynamic route or modal loading
button.addEventListener("click", async () => {
const { renderModal } = await import(
/* webpackChunkName: "modal" */ "./components/Modal"
);
renderModal();
});
```
### Long-Term Caching Optimization
**Problem**: Ensure updated bundles bust browser cache while unchanged vendor libraries remain cached.
**Solution**: Separate runtime chunk and extract vendor libraries.
```javascript
module.exports = {
optimization: {
runtimeChunk: "single",
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
chunks: "all",
},
},
},
},
};
```
## Best Practices
**Do**:
- Enable `cache: { type: "filesystem" }` in Webpack 5 to dramatically reduce CI/CD build times.
- Use `swc-loader` or `esbuild-loader` in place of `babel-loader` for up to 10x faster transpilation.
- Use `[contenthash:8]` in production output filenames for optimal long-term browser HTTP caching.
- Externalize and isolate shared dependencies with `singleton: true` in Module Federation.
**Don't**:
- Build large production SPAs without configuring `splitChunks` to separate vendor and application code.
- Include expensive development plugins (e.g. detailed source map generators) in production configurations.
- Commit `dist/` or `.cache/` build output directories to version control.
## Troubleshooting
| Error | Cause | Solution |
| ----------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `Module not found: Error: Can't resolve '...'` | File extension missing from `resolve.extensions` array | Add `resolve: { extensions: ['.ts', '.tsx', '.js', '.json'] }` to `webpack.config.js`. |
| Out of memory (`JavaScript heap out of memory`) | Heavy source maps or source analysis on large dependency graph | Switch `devtool` to `eval-cheap-module-source-map` for development; exclude `node_modules` from loaders. |
| Injected styles not showing in production | `style-loader` used instead of extracting CSS in production | Use `MiniCssExtractPlugin.loader` in production builds instead of `style-loader`. |
## References
- [Webpack Documentation](https://webpack.js.org/)
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · G1Joshi/Agent-Skills | 100 | MIT |
| claude-dev-suite/claude-dev-suite | 100 | MIT |
| dkbnull/hello-skill | 90 | MIT |
Database snapshot: 13.11.2026 · package version 73e7183b548a (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100bootstrap-webpack
Include and bundle Bootstrap 6's CSS and JavaScript in a project using Webpack. Use when setting up Bootstrap with Webpack, configuring Webpack loaders for Bootstrap's Sass and JS, or creating a Webpack-based Bootstrap project. - 100micro-frontends-module-federation
Use this skill when orchestrating independently deployed frontend applications at runtime using Webpack or Vite Module Federation. - 100parcel
Expert Parcel assistance covering zero-configuration bundling, transformer plugins, SVG/CSS/SCSS asset pipelines, code splitting, and multi-target builds. Use when bundling web apps without complex Webpack setups, configuring .parcelrc, debugging build caches, or compiling modern JavaScript. - 100rsbuild
Rsbuild is a Rspack-based build tool for web applications with a built-in dev server, TypeScript, CSS and asset support, and 5 to 10 times faster builds than webpack. Use when a developer asks to set up Rsbuild for React, Vue, Svelte or vanilla projects, migrate from webpack,… - 100turbopack
Turbopack is the Rust-based incremental bundler built into Next.js, the default for next dev and next build since Next.js 16. Use when someone asks to configure Turbopack, migrate a webpack config or loaders to the turbopack option in next.config, fix a Turbopack build error, or… - 95frontend-bundler-tools
Use this skill when the user says 'bundler', 'Vite', 'Webpack', 'Turbopack', 'build tool', 'bundle config', 'build optimization', 'tree shaking', 'code splitting', 'lazy loading', 'chunk splitting', 'asset bundling', 'build performance', 'bundler migration'. Configure and…