/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/hot-module-replacement/webpack.config.js
51 строка
1 KB
Alexander Akait
docs: add Hot Module Replacement examples for web, node and universal (#21222)
19 июн 2026, 13:54
Не верифицирован
19 июн 2026, 13:54
5ee4706
Код
Авторство
О чём код?
"use strict"; const path = require("path"); const { HotModuleReplacementPlugin } = require("../../"); // `webpack` resolves to this repo only because the example lives inside it; // real projects can drop this alias and import `webpack/hot/*` directly. /** @type {import("../../").Configuration} */ const base = { mode: "development", context: __dirname, devtool: false, resolve: { alias: { webpack: path.resolve(__dirname, "../../") } }, plugins: [new HotModuleReplacementPlugin()] }; /** @type {import("../../").Configuration[]} */ const config = [ // Web — driven by webpack-dev-server (`webpack serve`). { ...base, name: "web", target: "web", entry: "./web.js", output: { path: path.resolve(__dirname, "dist/web"), filename: "main.js" } }, // Node — driven by webpack/hot/poll (`webpack --watch` + `node dist/node/main.js`). { ...base, name: "node", target: "node", entry: "./node.js", output: { path: path.resolve(__dirname, "dist/node"), filename: "main.js" } }, // Universal — single ESM bundle for web + Node, one dev-server client. { ...base, name: "universal", target: ["web", "node"], entry: "./universal.js", experiments: { outputModule: true }, output: { path: path.resolve(__dirname, "dist/universal"), filename: "main.mjs", module: true, chunkFormat: "module" } } ]; module.exports = config;