{"record":{"id":"8ab7d01eb50740f3","repo":"DioxusLabs/dioxus","slug":"css-module-file-should-end-with-a-css-suff","errorCode":null,"errorMessage":"Css module file `{}` should end with a `.css` suffix.","messagePattern":"Css module file `(.+?)` should end with a `\\.css` suffix\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"packages/cli/src/opt/css.rs","lineNumber":65,"sourceCode":"    css_options: &CssModuleAssetOptions,\n    source: &Path,\n    output_path: &Path,\n) -> anyhow::Result<()> {\n    let css = std::fs::read_to_string(source)?;\n\n    // Collect the file hash name.\n    let mut src_name = source\n        .file_name()\n        .and_then(|x| x.to_str())\n        .ok_or_else(|| {\n            anyhow!(\n                \"Failed to read name of css module file `{}`.\",\n                source.display()\n            )\n        })?\n        .strip_suffix(\".css\")\n        .ok_or_else(|| {\n            anyhow!(\n                \"Css module file `{}` should end with a `.css` suffix.\",\n                source.display(),\n            )\n        })?\n        .to_string();\n\n    src_name.push('-');\n\n    let hash = create_module_hash(source);\n    let css = transform_css(css.as_str(), hash.as_str()).map_err(|error| {\n        anyhow!(\n            \"Invalid css for file `{}`\\nError:\\n{}\",\n            source.display(),\n            error\n        )\n    })?;\n\n    // Minify CSS","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/393d190a801ccb441d41923e232289b4f8a5c669/packages/cli/src/opt/css.rs#L47-L83","documentation":"After reading the file name, process_css_module requires a literal .css suffix so it can strip it and build the hashed module name; strip_suffix(\".css\") failing produces this error. Normally only .css files are routed here, so seeing it means a file without an exact .css ending reached CSS-module processing.","triggerScenarios":"Registering or configuring a CSS module whose path does not end exactly with .css — an uppercase .CSS extension on a case-sensitive filesystem, or a .scss/.txt file mistakenly passed with css-module options.","commonSituations":"Renaming files on case-sensitive Linux CI after developing on macOS/Windows; preprocessing pipelines forwarding .scss output under the wrong extension.","solutions":["Rename the file so it ends exactly with lowercase .css (e.g. Button.module.css)","Route other extensions through their own preprocessor step and emit .css before the css-module pass","Check for trailing whitespace or double extensions in the file name (Button.module.css.txt)"],"exampleFix":"// before: does not end with a literal .css suffix\n\"assets/buttons.module.CSS\"  // fails on case-sensitive filesystems\n\n// after\n\"assets/buttons.module.css\"","handlingStrategy":"validation","validationCode":"// Guard before processing\nfn is_css_module(p: &std::path::Path) -> bool {\n    p.file_name().and_then(|n| n.to_str()).map_or(false, |n| n.ends_with(\".css\"))\n}","typeGuard":"fn is_css_module(p: &std::path::Path) -> bool {\n    p.file_name().and_then(|n| n.to_str()).map_or(false, |n| n.ends_with(\".css\"))\n}","tryCatchPattern":null,"preventionTips":["Name modules with the exact lowercase .module.css suffix","Beware case-only differences when moving projects onto Linux CI","Ensure preprocessors emit .css files before the css-module pipeline sees them"],"tags":["cli","css-modules","assets","file-extension"],"backgroundTag":null,"analyzedSha":"393d190a801ccb441d41923e232289b4f8a5c669","analyzedAt":"2026-08-16T11:27:45.815Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}