/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/configCases/html/css-multi-entry-order/test.js
23 строки
786 B
Raj Aryan
fix(html): emit stylesheet links before all script tags (#21231)
22 июн 2026, 18:15
Не верифицирован
22 июн 2026, 18:15
ff19f17
Код
Авторство
О чём код?
const fs = require("fs"); const path = require("path"); const readFile = (name) => fs.readFileSync(path.resolve(__dirname, name), "utf-8"); it("emits every stylesheet <link> before any <script>", () => { const html = readFile("page.html"); const firstScriptIdx = html.indexOf("<script"); const lastLinkIdx = html.lastIndexOf('<link rel="stylesheet"'); expect(lastLinkIdx).toBeGreaterThan(-1); expect(lastLinkIdx).toBeLessThan(firstScriptIdx); // Both entries' CSS reach the HTML, in document (cascade) order. const linkHrefs = []; const linkRe = /<link rel="stylesheet" href="([^"]+)">/g; for (let m; (m = linkRe.exec(html)); ) linkHrefs.push(m[1]); expect(linkHrefs).toHaveLength(2); for (const href of linkHrefs) { expect(() => readFile(href)).not.toThrow(); } });