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(defineConfig): enable conditional return #979

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ineshbose
Copy link
Collaborator

@ineshbose ineshbose commented Apr 9, 2025

resolves #842

Copy link

what-the-diff bot commented Apr 9, 2025

PR Summary

  • Enhanced Configuration Flexibility in tailwind.config.ts File
    This change includes an update in the tailwind.config.ts file, utilizing the newly defined defineConfig function imported from src/config.ts. This enhancement improves the flexibility of configuration management.

  • Determination of Running Context within the defineConfig Function
    New logic has been implemented in the defineConfig function. This decides if the current context is Nuxt, a popular framework for developing Vue.js applications, and changes how configurations are processed accordingly.

  • Tailored Configuration Based on Running Context
    We've improved the defineConfig function further to return configurations suited to the specific running context. This means it can respond differently based on whether it's being run as a main file or within a Nuxt Environment. This upgrade improves our ability to handle different scenarios with maximum efficiency.

Copy link

netlify bot commented Apr 9, 2025

Deploy Preview for nuxt-tailwindcss ready!

Name Link
🔨 Latest commit 59448f5
🔍 Latest deploy log https://app.netlify.com/sites/nuxt-tailwindcss/deploys/67f69e91a0dc4a0008f4cff8
😎 Deploy Preview https://deploy-preview-979--nuxt-tailwindcss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

const _defineConfig = createDefineConfig<Partial<Config>>()
export const defineConfig: typeof _defineConfig = (config) => {
const isNuxt = !!tryUseNuxt()
return isNuxt ? config : isMainFile ? requireModule('.nuxt/tailwind/postcss.mjs') : config
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielroe

Could I get a review here possibly?

The use-case is for IntelliSense - if it is used in Nuxt build-time, just return the defined config.

If it is being loaded from the IntelliSense plugin, return .nuxt/tailwind/postcss.mjs contents which will in-turn re-import this file/config, so if it is being imported from there, return the object instead of trying to re-require postcss.mjs causing a cyclic import.

Quite fragile stuff, but I'm thinking I could ship it and based on feedback, remove it if not helpful as it is a non-app functionality feature/change.

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.

[DX] Expose defineConfig utility
1 participant