webpack
БесплатноБез исполняемых скриптовНе проверенwebpack is a module bundler that turns a JavaScript project and its CSS, images and dependencies into optimized static files for the browser. Use when someone…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
webpack — bundle JavaScript, CSS and assets for the browser
Overview
webpack starts from one or more entry files, follows every import and require, passes each file through loaders (CSS, Babel, TypeScript, images), and writes bundles to an output directory. Plugins add whole-build behavior such as generating the HTML page or extracting CSS. Production mode minifies and tree-shakes by default.
Versions checked for this skill: webpack 5.112.x, webpack-cli 7.3.x, webpack-dev-server 6.1.x, html-webpack-plugin 5.6.x, mini-css-extract-plugin 2.10.x. Configuration lives in webpack.config.js in the project root.
Choose webpack when a project already uses it or needs its loader and plugin ecosystem, Module Federation, or fine control over chunks. For a new project the faster alternatives are vite and rspack (Rspack reads most webpack configs); a migration is covered by the use case "Migrate a Webpack Project to Vite for Faster Builds".
Instructions
Install
npm install --save-dev webpack webpack-cli webpack-dev-server html-webpack-plugin mini-css-extract-plugin css-loader style-loader
webpack-cli provides the webpack command; webpack-dev-server provides webpack serve. Add scripts to package.json:
{
"scripts": {
"dev": "webpack serve --mode development",
"build": "webpack --mode production"
}
}
Check the module system first. A "type": "commonjs" entry in package.json (written by npm init -y) makes webpack parse .js files as CommonJS, and the first import then fails with 'import' and 'export' may appear only with 'sourceType: module'. Delete the type field or set it to "module". With "type": "module" name the config webpack.config.cjs if it uses require (webpack-cli finds it automatically).
A complete config
// webpack.config.js
const path = require("node:path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = (env, argv) => {
const isProd = argv.mode === "production";
return {
entry: "./src/index.js",
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",
assetModuleFilename: "assets/[name].[hash:8][ext]",
clean: true,
},
devtool: isProd ? "source-map" : "eval-source-map",
module: {
rules: [
{
test: /\.css$/i,
use: [isProd ? MiniCssExtractPlugin.loader : "style-loader", "css-loader"],
},
{ test: /\.(png|jpe?g|svg|woff2?)$/i, type: "asset" },
],
},
plugins: [
new HtmlWebpackPlugin({ template: "./public/index.html" }),
...(isProd ? [new MiniCssExtractPlugin({ filename: "css/[name].[contenthash:8].css" })] : []),
],
optimization: {
splitChunks: { chunks: "all" },
runtimeChunk: "single",
},
performance: { maxEntrypointSize: 250000, maxAssetSize: 250000 },
devServer: { port: 5600, hot: true, historyApiFallback: true },
};
};
Notes on the keys: output.clean: true empties dist/ before each build; [contenthash] changes only when a file's content changes, which makes long-lived caching safe; type: "asset" is a built-in asset module (small files inline, larger ones are emitted), so no file-loader or url-loader; runtimeChunk: "single" keeps the webpack runtime out of app chunks so their hashes stay stable; performance makes webpack warn when an entry exceeds the limit (in bytes).
The exported function receives env (values from --env) and argv (including mode). Read the mode from argv.mode inside the config function.
Build, serve, watch
npx webpack --mode production # one-off build into dist/
npx webpack serve --mode development --port 5600 # dev server with HMR
npx webpack --watch --mode development # rebuild on change, no server
npx webpack configtest # validate the config file
npx webpack --mode production --env release=2026.11 # env arrives as {release: "2026.11", ...}
npx webpack info # versions of webpack, Node, loaders
A successful build ends with webpack 5.x compiled successfully. The dev server serves from memory; nothing appears in dist/ until a real build.
Code splitting
Dynamic import() creates a separate chunk that is downloaded on demand; a magic comment names it:
document.addEventListener("click", async () => {
const { renderReport } = await import(/* webpackChunkName: "report" */ "./pages/report.js");
renderReport(document.querySelector("#app"));
});
splitChunks: { chunks: "all" } additionally moves shared and node_modules code into vendor chunks. In the sample project a production build emitted a 19 KB vendor chunk, a
Установить webpack в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл webpack?
webpack is a module bundler that turns a JavaScript project and its CSS, images and dependencies into optimized static files for the browser. Use when someone asks to "set up webpack", "write a webpack config", "split my bundle", "fix a huge bundle", "add content hashes for caching", "run the webpack dev server", "analyze bundle size", or to debug a webpack build error. Covers webpack 5 with webpack-cli 7, loaders, asset modules, code splitting, filesystem caching and bundle analysis.
Как установить скилл webpack?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл webpack запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic