Skip to content

3.1.0 fails scanning .slim templates for purging #8557

@ledermann

Description

@ledermann

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?

webpack@5.73.0, postcss@8.4.14

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions