{"id":"b1047bb5c8f5cebf","repo":"gohugoio/hugo","slug":"postcss-config-q-not-found","errorCode":null,"errorMessage":"postcss config %q not found","messagePattern":"postcss config %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/resource_transformers/cssjs/postcss.go","lineNumber":175,"sourceCode":"\tif options.Config != \"\" {\n\t\tconfigFile = options.Config\n\t} else {\n\t\tfor _, name := range []string{\"postcss.config.js\", \"postcss.config.mjs\", \"postcss.config.cjs\"} {\n\t\t\tconfigFile = t.rs.BaseFs.ResolveJSConfigFile(name)\n\t\t\tif configFile != \"\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif configFile != \"\" {\n\t\tconfigFile = filepath.Clean(configFile)\n\t\t// We need an absolute filename to the config file.\n\t\tif !filepath.IsAbs(configFile) {\n\t\t\tconfigFile = t.rs.BaseFs.ResolveJSConfigFile(configFile)\n\t\t\tif configFile == \"\" && options.Config != \"\" {\n\t\t\t\t// Only fail if the user specified config file is not found.\n\t\t\t\treturn fmt.Errorf(\"postcss config %q not found\", options.Config)\n\t\t\t}\n\t\t}\n\t}\n\n\tvar cmdArgs []any\n\n\tif configFile != \"\" {\n\t\tinfol.Logf(\"use config file %q\", configFile)\n\t\tcmdArgs = []any{\"--config\", configFile}\n\t}\n\n\tif optArgs := options.toArgs(); len(optArgs) > 0 {\n\t\tcmdArgs = append(cmdArgs, collections.StringSliceToInterfaceSlice(optArgs)...)\n\t}\n\n\tvar errBuf bytes.Buffer\n\n\tstderr := io.MultiWriter(infow, &errBuf)","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/resource_transformers/cssjs/postcss.go#L157-L193","documentation":"When running css.PostCSS, Hugo resolves the PostCSS config file: either the one the user names via the `config` option or an auto-discovered postcss.config.{js,mjs,cjs}. If the user explicitly specified a config path and BaseFs.ResolveJSConfigFile cannot find it (relative to the project/theme mounts), Hugo errors out rather than running postcss without it. Auto-discovery failures are silent; only an explicit, missing `config` fails.","triggerScenarios":"`{{ $css := $scss | css.PostCSS (dict \"config\" \"path/to/postcss.config.js\") }}` (or resources.PostCSS) where that path doesn't resolve within the project's mounted filesystems; absolute-looking paths outside the working dir; wrong filename or directory.","commonSituations":"Config file lives outside the Hugo working dir or isn't mounted (themes/modules without the file mounted); typo in the path; CI checkout missing the file; passing a directory instead of a file (the option may be a directory containing postcss.config.js — verify it exists).","solutions":["Verify the path passed in the `config` option exists relative to the project root (or a mounted theme/module dir).","Place postcss.config.js in the project root and drop the `config` option to use auto-discovery.","If the config comes from a module/theme, ensure it's included via module mounts.","In CI, confirm the file is checked out and not gitignored."],"exampleFix":"// before (template)\n{{ $css := $styles | css.PostCSS (dict \"config\" \"build/postcss.conf.js\") }}\n// after — file at project root, auto-discovered\n{{ $css := $styles | css.PostCSS }}","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(filepath.Join(projectDir, \"postcss.config.js\")); err != nil {\n    // create it or drop the config option\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Commit postcss.config.js at the project root (or the path you pass via the `config` option)","If you pass `config` to css.PostCSS, make it a path that exists relative to the working dir","Run `npm install` so postcss-cli and the config's plugins resolve"],"tags":["hugo","postcss","css","build-tools","config"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}