Skip to content

Commit

Permalink
allow setting the prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
jantimon committed Dec 6, 2024
1 parent 0b95fc1 commit ca852b5
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/next-yak/withYak/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const { resolve } = createRequire(currentDir + "/index.js");

export type YakConfigOptions = {
contextPath?: string;
/**
* Optional prefix for generated CSS identifiers.
* This can be used to ensure unique class names across different applications
* or to add organization-specific prefixes.
*/
prefix?: string;
experiments?: {
debug?:
| boolean
Expand All @@ -32,7 +38,11 @@ const addYak = (yakOptions: YakConfigOptions, nextConfig: NextConfig) => {
nextConfig.experimental.swcPlugins ||= [];
nextConfig.experimental.swcPlugins.push([
resolve("yak-swc"),
{ devMode: process.env.NODE_ENV !== "production", basePath: currentDir },
{
devMode: process.env.NODE_ENV !== "production",
basePath: currentDir,
prefix: yakOptions.prefix
},
]);

nextConfig.webpack = (webpackConfig, options) => {
Expand Down Expand Up @@ -104,7 +114,9 @@ function resolveYakContext(contextPath: string | undefined, cwd: string) {
* // your next config here
* };
* const yakConfig = {
* // your yak config
* // Optional prefix for generated CSS identifiers
* prefix: "my-app",
* // Other yak config options...
* };
* module.exports = withYak(yakConfig, nextConfig);
* ```
Expand Down Expand Up @@ -150,4 +162,4 @@ export const withYak: {
};
}
return addYak(yakOptions, nextConfig);
};
};

0 comments on commit ca852b5

Please sign in to comment.