diff --git a/packages/angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.ts b/packages/angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.ts index 8c021d8e8e6a..fdf8d969bd87 100644 --- a/packages/angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.ts +++ b/packages/angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.ts @@ -10,7 +10,7 @@ import type { OnLoadResult, Plugin, PluginBuild } from 'esbuild'; import glob from 'fast-glob'; import assert from 'node:assert'; import { readFile } from 'node:fs/promises'; -import { extname } from 'node:path'; +import { extname, isAbsolute } from 'node:path'; import type { PostcssConfiguration } from '../../../utils/postcss-configuration'; import { LoadResultCache, createCachedLoad } from '../load-result-cache'; @@ -167,6 +167,12 @@ export class StylesheetPluginFactory { build.onLoad( { filter: language.fileFilter }, createCachedLoad(cache, async (args) => { + if (!isAbsolute(args.path)) { + // The file being requested might be using the HTTP protocol. + // Example: `@import url(https://fonts.googleapis.com/earlyaccess/notokufiarabic.css);` + return null; + } + const data = await readFile(args.path, 'utf-8'); return processStylesheet( diff --git a/tests/legacy-cli/e2e/tests/build/styles/tailwind-v3.ts b/tests/legacy-cli/e2e/tests/build/styles/tailwind-v3.ts index 0dbb42f1025e..aa47808d8203 100644 --- a/tests/legacy-cli/e2e/tests/build/styles/tailwind-v3.ts +++ b/tests/legacy-cli/e2e/tests/build/styles/tailwind-v3.ts @@ -15,7 +15,14 @@ export default async function () { await writeFile('src/app/app.component.css', '@tailwind base; @tailwind components;'); // Add Tailwind directives to a global style - await writeFile('src/styles.css', '@tailwind base; @tailwind components;'); + await writeFile( + 'src/styles.css', + ` + @import url(https://fonts.googleapis.com/css?family=Roboto:400); + @tailwind base; + @tailwind components; + `, + ); // Ensure installation warning is present const { stderr } = await ng('build', '--configuration=development');