vitejs/vite · error · Error
base or replace is required
Error message
base or replace is required
What it means
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.
Source
Thrown at packages/vite/src/node/plugins/css.ts:2096
) => string | false | Promise<string | false>
// https://drafts.csswg.org/css-syntax-3/#identifier-code-point
export const cssUrlRE: RegExp =
/(?<!@import\s+)(?<=^|[^\w\-\u0080-\uffff])url\((\s*('[^']+'|"[^"]+")\s*|(?:\\.|[^'")\\])+)\)/
export const cssDataUriRE: RegExp =
/(?<=^|[^\w\-\u0080-\uffff])data-uri\((\s*('[^']+'|"[^"]+")\s*|[^'")]+)\)/
export const importCssRE: RegExp =
/@import\s+(?:url\()?('[^']+\.css'|"[^"]+\.css"|[^'"\s)]+\.css)/
// Assuming a function name won't be longer than 256 chars
// eslint-disable-next-line regexp/no-unused-capturing-group -- doesn't detect asyncReplace usage
const cssImageSetRE = /(?<=image-set\()((?:[\w-]{1,256}\([^)]*\)|[^)])*)(?=\))/
const UrlRewritePostcssPlugin: PostCSS.PluginCreator<{
resolver: CssUrlResolver
deps: Set<string>
logger: Logger
}> = (opts) => {
if (!opts) {
throw new Error('base or replace is required')
}
return {
postcssPlugin: 'vite-url-rewrite',
OnceExit(root) {
const promises: Promise<void>[] = []
root.walkDecls((declaration) => {
const importer = declaration.source?.input.file
if (!importer) {
opts.logger.warnOnce(
'\nA PostCSS plugin did not pass the `from` option to `postcss.parse`. ' +
'This may cause imported assets to be incorrectly transformed. ' +
"If you've recently added a PostCSS plugin that raised this warning, " +
'please contact the package author to fix the issue.',
)
}
const isCssUrl = cssUrlRE.test(declaration.value)
const isCssImageSet = cssImageSetRE.test(declaration.value)View on GitHub (pinned to 89620f09af)
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.
Defensive patterns
Strategy: validation
Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- HTML proxy index in "${id}" not found
- Failed to load PostCSS config: ${e}
- Unknown lang: ${lang}
- Unsupported dependency type: ${dep.type}
- When "build.cssCodeSplit: false" is set, "rolldownOptions.in
AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03).
Data as JSON: /data/errors/132101e51c1f065f.json.
Report an issue: GitHub.