{"record":{"id":"0d52a2de7e373e99","repo":"tailwindlabs/tailwindcss","slug":"config-cannot-be-nested","errorCode":null,"errorMessage":"`@config` cannot be nested.","messagePattern":"`@config` cannot be nested\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwindcss/src/compat/apply-compat-hooks.ts","lineNumber":133,"sourceCode":"          base: ctx.context.base as string,\n          reference: !!ctx.context.reference,\n          src: node.src,\n        },\n        Object.keys(options).length > 0 ? options : null,\n      ])\n\n      features |= Features.JsPluginCompat\n      return WalkAction.Replace([])\n    }\n\n    // Collect paths from `@config` at-rules\n    if (node.name === '@config') {\n      if (node.nodes.length > 0) {\n        throw new Error('`@config` cannot have a body.')\n      }\n\n      if (ctx.parent !== null) {\n        throw new Error('`@config` cannot be nested.')\n      }\n\n      configPaths.push({\n        id: node.params.slice(1, -1),\n        base: ctx.context.base as string,\n        reference: !!ctx.context.reference,\n        src: node.src,\n      })\n      features |= Features.JsPluginCompat\n      return WalkAction.Replace([])\n    }\n  })\n\n  registerLegacyUtilities(designSystem)\n\n  // Override `resolveThemeValue` with a version that is backwards compatible\n  // with dot notation paths like `colors.red.500`. We could do this by default\n  // in `resolveThemeValue` but handling it here keeps all backwards","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/tailwindcss/src/compat/apply-compat-hooks.ts#L115-L151","documentation":"Thrown when an `@config` at-rule is nested inside another rule (`ctx.parent !== null`). Like `@plugin`, `@config` must be top-level so the referenced JS config loads at the correct phase.","triggerScenarios":"Writing `@config \"./tw.js\";` inside a `@layer`, `@media`, or selector. The walker tracks nesting via `ctx.parent`.","commonSituations":"Indenting `@config` under another rule by accident; merging config directives during refactor and losing the top-level position.","solutions":["Move the `@config` at-rule to the top level of the stylesheet.","Remove any wrapping block around `@config`."],"exampleFix":"// before\n@media (min-width: 768px) {\n  @config \"./tw.js\";\n}\n// after\n@config \"./tw.js\";","handlingStrategy":"validation","validationCode":"function assertConfigTopLevel(ast) {\n  walk(ast, (node, ctx) => {\n    if (node.kind === 'at-rule' && node.name === '@config' && ctx.parent !== null) {\n      throw new Error('@config must be top-level');\n    }\n  });\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep `@config` and `@plugin` at-rules at the stylesheet root.","Avoid nesting config directives during CSS refactors."],"tags":["tailwind","config","at-rule","nesting"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}