This error occurs when two different styles, refs, or animations would receive
the same generated name. The usual cause is a custom naming function that
returns the same name for different requests. A very short hashLength can also
cause it.
Reported
import { defineConfig } from "stillwind/config";
export default defineConfig({
projects: [
{
css: "./src/stillwind.css",
files: ["src/**/*.tsx"],
namingRevision: "1",
naming: {
utilityClass: () => "button",
},
},
],
});style("p-4");
style("p-8");SW03001: generated identifier collision: button
Fixed
import { defineConfig } from "stillwind/config";
export default defineConfig({
projects: [
{
css: "./src/stillwind.css",
files: ["src/**/*.tsx"],
namingRevision: "2",
naming: {
utilityClass: (_context, hash) => `button_${hash.toString("hex")}`,
},
},
],
});style("p-4");
style("p-8");How to fix
- Include the hash passed as the callback’s second argument in the name, as in
the example. This keeps the
buttonprefix while distinguishing requests. Returnnullto use the default name for a request. - If you use the default names, raise
hashLength. - Change
namingRevisionwhenever you change anamingfunction.