Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(transformer): support custom aliases #169

Merged
merged 1 commit into from
Mar 12, 2024

Conversation

Gomah
Copy link
Contributor

@Gomah Gomah commented Mar 12, 2024

Description

Add support for passing custom aliases in the custom TV Transformer.

Additional context

Currently, the transformer checks the files's content against the "tailwind-variants" constant to check whether or not the file should be transformed.

However, when creating a custom TV instance and importing it, the transformer will ignore it as it's not matching "tailwind-variants".

// @/lib/tv.ts
import { createTV } from 'tailwind-variants';
export type { VariantProps } from 'tailwind-variants';

export const tv = createTV({
  // my custom twMergeConfig.
});

The proposed change adds a configuration object to the withTV function to configure aliases:

// tailwind.config.js

const { withTV } = require('tailwind-variants/transformer')

/** @type {import('tailwindcss').Config} */
module.exports = withTV({
  content:  ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
  theme: {
    extend: {},
  },
  plugins: [],
}, {
  aliases: ["@/lib/tv"]
})

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Follow the Style Guide.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).

@mykz
Copy link

mykz commented Mar 12, 2024

Our team encountered this issue a while back, and we ended up naming our custom TV instance file tailwind-variants.ts. However, we did waste some time trying to debug the issue until delving into the TV transformer source code and finding the condition.

I was hoping to submit a PR, but time has slipped away, so I appreciate the effort put into this as it's a much-needed option within the transform.

@mskelton mskelton merged commit d6ac934 into nextui-org:main Mar 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants