{"id":"132101e51c1f065f","repo":"vitejs/vite","slug":"base-or-replace-is-required","errorCode":null,"errorMessage":"base or replace is required","messagePattern":"base or replace is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/plugins/css.ts","lineNumber":2096,"sourceCode":") => string | false | Promise<string | false>\n// https://drafts.csswg.org/css-syntax-3/#identifier-code-point\nexport const cssUrlRE: RegExp =\n  /(?<!@import\\s+)(?<=^|[^\\w\\-\\u0080-\\uffff])url\\((\\s*('[^']+'|\"[^\"]+\")\\s*|(?:\\\\.|[^'\")\\\\])+)\\)/\nexport const cssDataUriRE: RegExp =\n  /(?<=^|[^\\w\\-\\u0080-\\uffff])data-uri\\((\\s*('[^']+'|\"[^\"]+\")\\s*|[^'\")]+)\\)/\nexport const importCssRE: RegExp =\n  /@import\\s+(?:url\\()?('[^']+\\.css'|\"[^\"]+\\.css\"|[^'\"\\s)]+\\.css)/\n// Assuming a function name won't be longer than 256 chars\n// eslint-disable-next-line regexp/no-unused-capturing-group -- doesn't detect asyncReplace usage\nconst cssImageSetRE = /(?<=image-set\\()((?:[\\w-]{1,256}\\([^)]*\\)|[^)])*)(?=\\))/\n\nconst UrlRewritePostcssPlugin: PostCSS.PluginCreator<{\n  resolver: CssUrlResolver\n  deps: Set<string>\n  logger: Logger\n}> = (opts) => {\n  if (!opts) {\n    throw new Error('base or replace is required')\n  }\n\n  return {\n    postcssPlugin: 'vite-url-rewrite',\n    OnceExit(root) {\n      const promises: Promise<void>[] = []\n      root.walkDecls((declaration) => {\n        const importer = declaration.source?.input.file\n        if (!importer) {\n          opts.logger.warnOnce(\n            '\\nA PostCSS plugin did not pass the `from` option to `postcss.parse`. ' +\n              'This may cause imported assets to be incorrectly transformed. ' +\n              \"If you've recently added a PostCSS plugin that raised this warning, \" +\n              'please contact the package author to fix the issue.',\n          )\n        }\n        const isCssUrl = cssUrlRE.test(declaration.value)\n        const isCssImageSet = cssImageSetRE.test(declaration.value)","sourceCodeStart":2078,"sourceCodeEnd":2114,"githubUrl":"https://github.com/vitejs/vite/blob/89620f09afcfef6b35e7bb8660132ab5b4d0cd3b/packages/vite/src/node/plugins/css.ts#L2078-L2114","documentation":"Thrown by `UrlRewritePostcssPlugin` (the PostCSS plugin creator used internally to rewrite `url()` references in CSS) when it is invoked with no options object. The plugin needs at least `{ resolver, deps, logger }` to function; `opts` being falsy is an internal contract violation.","triggerScenarios":"The plugin creator function is called with `undefined`/`null` — i.e. `UrlRewritePostcssPlugin()` with no argument. This only happens inside Vite's own code path or a custom plugin that reuses the exported creator incorrectly.","commonSituations":"Not a typical user-facing error. Can surface if a third-party plugin imports `UrlRewritePostcssPlugin` from Vite internals and invokes it without options, or after a Vite internal refactor that broke the call site.","solutions":["Do not invoke Vite's internal `UrlRewritePostcssPlugin` directly from your own plugin.","If the error appears with stock Vite, update Vite — it indicates an internal regression.","Search your project and dependencies for `UrlRewritePostcssPlugin` usage and remove/fix it."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never import or invoke Vite's internal `UrlRewritePostcssPlugin` from app or plugin code.","Pin Vite to a stable version if you observe this — it signals an internal regression."],"tags":["css","postcss","internal","url"],"analyzedSha":"89620f09afcfef6b35e7bb8660132ab5b4d0cd3b","analyzedAt":"2026-08-03T19:28:02.920Z","schemaVersion":2}