/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/configCases/html/initial-chunk-modulepreload-default/webpack.config.js
47 строк
1 KB
Alexander Akait
feat: add output.resourceHints (preload / prefetch / modulepreload / preconnect emission) (#21463)
21 июл 2026, 13:46
Не верифицирован
21 июл 2026, 13:46
ece0fcb
Код
Авторство
О чём код?
"use strict"; // ESM output (`output.module`) defaults `resourceHints` on (Vite-style): the // entry's initial dependency chunks get `<link rel="modulepreload">` in the // HTML `<head>` WITHOUT any `output.resourceHints` set. Classic output stays // opt-in (see ../initial-chunk-preload-disabled). const fs = require("fs"); const path = require("path"); const webpack = require("../../../../"); /** @type {import("../../../../").Configuration} */ module.exports = { mode: "development", target: "web", entry: { page: "./page.html" }, output: { filename: "[name].mjs", chunkFilename: "[name].chunk.mjs", module: true // no `resourceHints` — defaulted on because output.module is true }, optimization: { chunkIds: "named", runtimeChunk: "single" }, experiments: { html: true, outputModule: true }, plugins: [ { apply(compiler) { compiler.hooks.compilation.tap("Test", (compilation) => { compilation.hooks.processAssets.tap( { name: "copy-test", stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL }, () => { const data = fs.readFileSync(path.resolve(__dirname, "test.js")); compilation.emitAsset( "test.js", new webpack.sources.RawSource(data) ); } ); }); } } ] };