Skip to content

Commit

Permalink
fix(build): import 'subresources' after setting puppeteer env (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidvishnoi authored May 29, 2024
1 parent 60b3790 commit 796e410
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/build.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as path from "path";
import { copyFile, mkdir, readFile, writeFile, unlink } from "fs/promises";
import fetch from "node-fetch";
import { getAllSubResources, ResourceType } from "subresources";
import { env, exit, setOutput, sh, unique } from "./utils.js";
import { deepEqual, StaticServer } from "./utils.js";
import { PUPPETEER_ENV } from "./constants.js";
import type { ResourceType } from "subresources";

import { BasicBuildOptions as BasicBuildOptions_ } from "./prepare-build.js";
import { ProcessedInput } from "./prepare.js";
Expand Down Expand Up @@ -172,16 +172,18 @@ async function findAssetsToCopy(source: Input["source"]) {
let localAssets: string[] = [];
let remoteAssets: URL[] = [];

Object.assign(process.env, PUPPETEER_ENV);
const {
getAllSubResources,
}: typeof import("subresources") = require("subresources");

const server = await new StaticServer().start();

const isLocalAsset = (url: URL) => url.origin === server.url.origin;
const remoteAssetRules: ((url: URL, type: ResourceType) => boolean)[] = [
(url: URL) => url.origin === "https://user-images.githubusercontent.com",
];

process.env["PUPPETEER_EXECUTABLE_PATH"] =
PUPPETEER_ENV.PUPPETEER_EXECUTABLE_PATH;

const mainPage = urlToPage(new URL(tmpOutputFile(source), server.url));
const pages = new Set([mainPage]);
for (const page of pages) {
Expand Down

0 comments on commit 796e410

Please sign in to comment.