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(#176): tailwind v3.x safelisting #194

Merged

Conversation

MichalBryxi
Copy link
Contributor

@MichalBryxi MichalBryxi commented Feb 2, 2022

The safelist won't work with JIT the way it worked before, because:

The safelist option does not support regular expressions. Because no CSS is generated by default, the safelist has to be a list of complete class names. It’s not possible to safelist a regular expression, because there is not a pre-generated list of class names to match against that regular expression.

From tailwind v3.x the documentation hints that safelist using regular expressions matching would work.

Fixes #176

The [safelist](https://frontile.dev/docs/installation#using-the-safelist-config-option) won't [work with JIT](https://v2.tailwindcss.com/docs/just-in-time-mode#limitations) the way it worked before, because:

> The safelist option does not support regular expressions. Because no CSS is generated by default, the safelist has to be a list of complete class names. It’s not possible to safelist a regular expression, because there is not a pre-generated list of class names to match against that regular expression.

From tailwind [v3.x the documentation hints](https://tailwindcss.com/docs/content-configuration#using-regular-expressions) that `safelist` using regular expressions matching would work.
@MichalBryxi
Copy link
Contributor Author

I'm not sure whether it's responsibility of this addon to educate users to put respective paths into content key of tailwind config, as all their styles would be purged without it anyway. But to give a hint:

'use strict';
// located in <app root>/config/tailwind/

const path = require('path');

const appRoot = path.join(__dirname, '../../');
const appEntry = path.join(appRoot, 'app');
const relevantFilesGlob = '**/*.{html,js,ts,hbs,gjs,gts}';

module.exports = {
  content: [path.join(appEntry, relevantFilesGlob)],
  safelist: [ ... ]
}

@josemarluedke josemarluedke merged commit f973950 into josemarluedke:main Feb 2, 2022
@josemarluedke
Copy link
Owner

@MichalBryxi Thanks for the PR.

I think that could be a section in the documentation where we give another option instead of safelist. If we set content and include node_modules/@frontile, that would work as well.

@josemarluedke josemarluedke added the Type: Documentation Improvements or additions to documentation label Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

purge safelist won't work with JIT
2 participants