/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/configCases/html/parser-template/webpack.config.js
49 строк
1 KB
Alexander Akait
feat(html): add module.parser.html.template option (#21055)
29 май 2026, 16:56
Не верифицирован
29 май 2026, 16:56
4fbec23
Код
Авторство
О чём код?
"use strict"; /** @type {import("../../../../").Configuration} */ module.exports = { target: "web", module: { parser: { html: { template: ( source, { module, resource, addDependency, addContextDependency, addMissingDependency, addBuildDependency, emitWarning, emitError } ) => { if (typeof resource !== "string" || !module) { throw new Error("Expected module and resource in the context"); } if ( typeof addDependency !== "function" || typeof addContextDependency !== "function" || typeof addMissingDependency !== "function" || typeof addBuildDependency !== "function" || typeof emitWarning !== "function" || typeof emitError !== "function" ) { throw new Error("Incomplete html template context"); } // Exercise the dependency helpers (harmless paths). addDependency(resource); addContextDependency(require("path").dirname(resource)); addBuildDependency(resource); return source .replace(/\{\{title\}\}/g, "Hello world") .replace(/\{\{image\}\}/g, "./image.png"); } } } }, experiments: { html: true } };