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

3.1.0 fails scanning .slim templates for purging #8557

Closed
ledermann opened this issue Jun 9, 2022 · 0 comments · Fixed by #8569
Closed

3.1.0 fails scanning .slim templates for purging #8557

ledermann opened this issue Jun 9, 2022 · 0 comments · Fixed by #8569

Comments

@ledermann
Copy link

ledermann commented Jun 9, 2022

What version of Tailwind CSS are you using?

v3.1.0

What build tool (or framework if it abstracts the build tool) are you using?

[email protected], [email protected]

What version of Node.js are you using?

v18.3.0

What browser are you using?

Not relevant here

What operating system are you using?

Not relevant here


In a Ruby on Rails application, I'm using Slim templates which look like this:

p.bg-red-500.text-sm
  'This is a paragraph
  small.italic.text-gray-500 
    '(Look mom, no closing tag!)

With Tailwind CSS v3.0.24 this works fine, which means that Tailwind recognizes the classes correctly.

But after upgrading to v3.1.0 this is broken - maybe because of the dots instead of spaces (see #8553 for a similar issue). Classes defined this way are purged from the resulting stylesheet.

I've built this workaround by transforming to HTML:

// tailwind.config.js
var execSync = require('child_process').execSync;

// Converts Slim to HTML
function compileToHTML(source) {
  return execSync(`slimrb --stdin --erb`, {
    input: source,
  }).toString();
}

module.exports = {
  ...

  content: {
    files: [
      './app/**/*.{html,html.erb,rb,html.slim}',
      './app/javascript/**/*.js',
    ],
    transform: {
      slim: (content) => compileToHTML(content),
    },
  },

  ...
};

This works, but seems like a hack. Is there a chance for an official fix?

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 a pull request may close this issue.

1 participant