/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/configCases/html/initial-chunk-preload-string/webpack.config.js
52 строки
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"; // `resourceHints: "preload"` is a spelled-out alias of `true` — it must emit the // same `<link rel="preload" as="script">` for the entry's initial dependency // chunks as `resourceHints: true` does (see ../initial-chunk-preload). 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].js", chunkFilename: "[name].chunk.js", resourceHints: "preload" }, optimization: { chunkIds: "named", runtimeChunk: "single" }, experiments: { html: 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) ); } ); }); } } ] };