@@ -162,18 +162,20 @@ const setUpEdgeFunction = async ({ angularJson, constants, failBuild, usedEngine
162162 const serverDistFolder = dirname(fileURLToPath(import.meta.url));
163163 const browserDistFolder = resolve(serverDistFolder, 'browser');
164164
165- // fs.readFile is not supported in Edge Functions, so this is a workaround for CSS inlining
166- // that will intercept readFile attempt and if it's a CSS file, return the content from the manifest
167- const originalReadFile = globalThis.Deno.readFile
168- globalThis.Deno.readFile = (...args) => {
169- if (args.length > 0 && typeof args[0] === 'string') {
170- const relPath = relative(browserDistFolder, args[0])
171- if (relPath in cssAssetsManifest) {
172- return Promise.resolve(Buffer.from(cssAssetsManifest[relPath], 'base64'))
165+ if (typeof Deno !== 'undefined') {
166+ // fs.readFile is not supported in Edge Functions, so this is a workaround for CSS inlining
167+ // that will intercept readFile attempt and if it's a CSS file, return the content from the manifest
168+ const originalReadFile = globalThis.Deno.readFile
169+ globalThis.Deno.readFile = (...args) => {
170+ if (args.length > 0 && typeof args[0] === 'string') {
171+ const relPath = relative(browserDistFolder, args[0])
172+ if (relPath in cssAssetsManifest) {
173+ return Promise.resolve(Buffer.from(cssAssetsManifest[relPath], 'base64'))
174+ }
173175 }
176+
177+ return originalReadFile.apply(globalThis.Deno, args)
174178 }
175-
176- return originalReadFile.apply(globalThis.Deno, args)
177179 }
178180
179181 export default async (request, context) => {
0 commit comments