{"record":{"id":"8e6ede53fdb83973","repo":"gohugoio/hugo","slug":"failed-to-resolve-css-import-s-s","errorCode":null,"errorMessage":"failed to resolve CSS @import \"%s\"; %s","messagePattern":"failed to resolve CSS @import \"(.+?)\"; (.+?)","errorType":"exception","errorClass":"FileError","httpStatus":null,"severity":"error","filePath":"resources/resource_transformers/cssjs/inline_imports.go","lineNumber":163,"sourceCode":"\n\t\t\tif importContent == nil {\n\t\t\t\timp.dependencyManager.AddIdentity(identity.CleanStringIdentity(filename))\n\t\t\t\timportContent, hash = imp.contentHash(filename)\n\t\t\t\tnestedInPath = filepath.ToSlash(filename)\n\t\t\t}\n\n\t\t\tif importContent == nil {\n\t\t\t\tif imp.opts.SkipInlineImportsNotFound {\n\t\t\t\t\ttrackLine(i, offset, line)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tpos := text.Position{\n\t\t\t\t\tFilename:     inPath,\n\t\t\t\t\tLineNumber:   offset + 1,\n\t\t\t\t\tColumnNumber: column + 1,\n\t\t\t\t}\n\t\t\t\tmsgDetail := \"if this import's source lives in node_modules, enable the skipInlineImportsNotFound option, see https://gohugo.io/functions/css/postcss/#skipinlineimportsnotfound\"\n\t\t\t\treturn 0, \"\", herrors.NewFileErrorFromFileInPos(fmt.Errorf(\"failed to resolve CSS @import \\\"%s\\\"; %s\", filename, msgDetail), pos, imp.fs, nil)\n\t\t\t}\n\n\t\t\ti--\n\n\t\t\tif imp.contentSeen[hash] {\n\t\t\t\ti++\n\t\t\t\t// Just replace the line with an empty string.\n\t\t\t\treplacements = append(replacements, []string{line, \"\"}...)\n\t\t\t\ttrackLine(i, offset, \"IMPORT\")\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\timp.contentSeen[hash] = true\n\n\t\t\t// Handle recursive imports.\n\t\t\tl, nested, err := imp.importRecursive(i+lineNum, string(importContent), nestedInPath)\n\t\t\tif err != nil {\n\t\t\t\treturn 0, \"\", err","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/resource_transformers/cssjs/inline_imports.go#L145-L181","documentation":"Thrown by the CSS inline-import resolver when an @import statement in a CSS/SCSS file cannot be resolved to a resource in the import context or to a file on disk, and SkipInlineImportsNotFound is false. The message includes a hint to enable skipInlineImportsNotFound for node_modules-sourced imports.","triggerScenarios":"A CSS file passed to css.PostCSS (with inlining) or the cssjs inline-imports transformer contains `@import \"missing.css\";` where missing.css is neither a Hugo resource nor a resolvable filesystem path. Reached when imp.importContent == nil after both importContext.Get and contentHash fail.","commonSituations":"Importing a CSS file that lives only in node_modules without enabling skipInlineImportsNotFound, a typo in an @import path, referencing a partial that was deleted, or moving SCSS files without updating @import URLs.","solutions":["Correct the @import path to point at an existing resource or file.","If the import targets node_modules/vendor CSS that is already bundled by PostCSS, set options[\"skipInlineImportsNotFound\"] = true so Hugo ignores unresolvable imports.","Add the missing file to your assets directory and reference it by its assets-relative path."],"exampleFix":"// before\n{{ $css := resources.Get \"css/main.css\" | css.PostCSS }}\n// main.css has @import \"tailwind/dist.css\" which is in node_modules\n\n// after\n{{ $css := resources.Get \"css/main.css\" | css.PostCSS (dict \"skipInlineImportsNotFound\" true) }}","handlingStrategy":"validation","validationCode":"// Walk CSS files and check each @import resolves to an asset file or resource.\nimport \"regexp\"\n\nvar importRe = regexp.MustCompile(`@import\\s+[\"']([^\"']+)[\"']`)\n\nfunc unresolvedImports(css, assetsDir string) []string {\n    var missing []string\n    for _, m := range importRe.FindAllStringSubmatch(css, -1) {\n        p := filepath.Join(assetsDir, m[1])\n        if _, err := os.Stat(p); err != nil { missing = append(missing, m[1]) }\n    }\n    return missing\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set skipInlineImportsNotFound=true when your CSS imports node_modules bundles already handled by PostCSS.","Keep all @import targets under assets/ and reference them by assets-relative paths.","Lint CSS @imports against the filesystem in CI before building."],"tags":["css","postcss","import-resolution","node-modules"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}