AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

CSS Url Not Processed When Custom Asset Rule For SVG Is Enabled In Next.Js

When a user adds a webpack rule with type 'asset/resource' (or similar asset module type) for SVG files in next.config.ts, CSS url() references to SVG files are no longer rewritten to the hashed static asset path, causing broken URLs in the built CSS.

mediumConfidence 75%Next.jsHydrationPages RouterAffected V16.2.0-Canary.35

Origin Analysis

Next.js's internal CSS processing relies on its default webpack handling for static assets. Adding a custom asset module rule for SVGs intercepts requests originating from CSS url(), preventing the css-loader from rewriting the path to the generated hashed asset. This exposes a design conflict between user-defined webpack asset rules and Next.js's built-in CSS asset pipeline.
1. Create a Next.js project with the provided next.config.ts that includes a webpack rule for SVG using type 'asset/resource' (or similar). 2. In a CSS file, reference an SVG using background: url("./img.svg"); 3. Run npm run dev or npm run build. 4. Inspect the generated CSS: the url remains "./img.svg" instead of being rewritten to "../media/img.8569dc29.svg".

Fixing Code Block

// next.config.ts import type { NextConfig } from 'next'; const nextConfig: NextConfig = { webpack(config, context) { // Add issuer condition to exclude requests that originate from CSS files config.module.rules.push({ test: /\.svg$/, issuer: { not: /\.(css|scss|sass)$/ }, type: 'asset/resource', }); return config; }, }; export default nextConfig;
By adding an issuer condition that excludes CSS files, the custom asset rule only applies to SVG imports from JavaScript/TypeScript modules. CSS url() requests are then handled by Next.js's default processing, which correctly rewrites the URL to the hashed static asset path.

Edge Case Audit

This workaround assumes that the custom asset rule is intended only for JavaScript imports. If the same SVG asset is also used in CSS without a separate rule, the CSS reference must continue to rely on Next.js's default handling. Upgrading Next.js may change internal webpack rule ordering, requiring re-evaluation of the issuer condition. Rollback is straightforward by removing the issuer property or the entire custom rule. No concurrency or threading issues are expected.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state