mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00

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
25 lines
529 B
TypeScript
25 lines
529 B
TypeScript
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")',
|
|
);
|