mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 04:39:10 +00:00
feat(bundle): support html entrypoint (#29856)
For instance `deno bundle --outdir dist index.html` It will find scripts referenced in the html, bundle them, and then update the paths in index.html for the bundled assets. Right now it doesn't handle other assets (from `link` elements), but it could
This commit is contained in:
parent
41ff38ae65
commit
4e4bbf2fcc
33 changed files with 1480 additions and 74 deletions
25
tests/specs/bundle/html/multiple-scripts-bundle.asserts.ts
Normal file
25
tests/specs/bundle/html/multiple-scripts-bundle.asserts.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { assertFileContains } from "./assert-helpers.ts";
|
||||
|
||||
let jsFile: string | undefined;
|
||||
Deno.readDirSync("./dist").forEach((entry) => {
|
||||
if (entry.name.endsWith(".js")) {
|
||||
jsFile = "./dist/" + entry.name;
|
||||
}
|
||||
});
|
||||
|
||||
if (!jsFile) {
|
||||
throw new Error("No .js file found");
|
||||
}
|
||||
|
||||
assertFileContains(
|
||||
"./dist/multiple-scripts.html",
|
||||
/src="\.\/multiple-scripts-[^\.]+\.js"/,
|
||||
);
|
||||
assertFileContains(
|
||||
jsFile,
|
||||
'insertAdjacentHTML("beforeend", "A")',
|
||||
);
|
||||
assertFileContains(
|
||||
jsFile,
|
||||
'insertAdjacentHTML("beforeend", "B")',
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue