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

fix(windicss): support transforming dist files #327

Merged
merged 4 commits into from
May 24, 2021
Merged

Conversation

harlan-zw
Copy link
Collaborator

Supports the @apply in dist css and vue files to be transformed.

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

The Windi CSS package won't parse any files that are within an exclude glob. To get around this we added a special config extraTransformTargets that contains file paths that should be transformed.

For it to work we need to add all files that need to be transformed within that config, which is what this PR is doing.

Have tested this with the @nuxt/img package and all seems to be working correctly without any extra configuration.

image

@vercel
Copy link

vercel bot commented May 23, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/nuxtlabs/docus/8jZi4s6RQPoXbszmcNmfZiSnhvkN
✅ Preview: https://docus-git-fix-windicss-transforms-nuxtlabs.vercel.app

@harlan-zw harlan-zw requested a review from Tahul May 23, 2021 04:27
// Merge user and theme Windi configs
windiOptions.config = defu.arrayFn(windiOptions.config || {}, localWindiConfig || {}, defaultWindiConfig)

// Include local & npm depencies directories in scan process
windiOptions.scanOptions.dirs.push(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this only works before the options have been resolved, this hook is run after the options are resolved though

so the include below should be good enough

join(options.rootDir, '/node_modules/docus/dist'),
join(options.themeDir)
const transformFiles = await fg(
'**/*.{vue,css}',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if you have any other style file type in the future with @apply's it will need to be added here


const glob = '/**/*.{html,vue,md,mdx,pug,jsx,tsx,svelte,css}'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just cleaned this up a little and added css so that the scan will find them

@Tahul
Copy link
Contributor

Tahul commented May 24, 2021

Hey @harlan-zw ; thanks for that! 🙏

@Tahul Tahul merged commit 4ac1a90 into main May 24, 2021
@Tahul Tahul deleted the fix/windicss-transforms branch May 24, 2021 10:10
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.

2 participants