/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/configCases/html/preload-prefetch/index.js
28 строк
1 KB
Alexander Akait
feat(html): add `html` source type for linking HTML pages (#21346)
06 июл 2026, 22:32
Не верифицирован
06 июл 2026, 22:32
6ed4473
Код
Авторство
О чём код?
import page from "./page.html"; it("should rewrite <link rel=preload/prefetch> of a bundled script/style to chunk URLs", () => { expect(typeof page).toBe("string"); expect(page).toMatchSnapshot(); // `as="script"` preload/prefetch → JS chunk URL, tag otherwise kept. expect(page).not.toContain('href="./preload-script.js"'); expect(page).not.toContain('href="./prefetch-script.js"'); expect(page).toMatch( /<link rel="preload" as="script" href="__html_[^"]+\.js">/ ); expect(page).toMatch( /<link rel="prefetch" as="script" href="__html_[^"]+\.js">/ ); // `as="style"` preload → CSS chunk URL. expect(page).not.toContain('href="./preload-style.css"'); expect(page).toMatch( /<link rel="preload" as="style" href="__html_[^"]+\.css">/ ); // `webpackIgnore` leaves the resource hint untouched. expect(page).toContain('<link rel="preload" as="script" href="./ignored.js">'); // A resource hint references exactly one URL — no sibling tags are injected. expect(page).not.toContain("<script"); });