haml / haml-rails

let your Gemfile do the talking
MIT License
1.04k stars 169 forks source link

Add HAML to watcher for Rails 7 apps using Tailwind? #177

Open matt17r opened 2 years ago

matt17r commented 2 years ago

I had to manually add the following line to tailwind.config.js in a rails 7 app using haml-rails to get the JIT compiler to work.

--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -2,6 +2,7 @@ module.exports = {
   mode: 'jit',
   purge: [
     './app/views/**/*.html.erb',
+    './app/views/**/*.html.haml',
     './app/helpers/**/*.rb',
     './app/javascript/**/*.js'
   ]

Is it worth including that in the install script? If so, do you want me to try my hand at a PR?

rafafdz commented 2 years ago

I would say this a concern from the tailwind gem rather than haml. If Haml starts supporting external libraries specifics in their own code, they would have to be actively mainting it and effectively depend in third parties, which is never a good thing I would say

gonzalezgjaime commented 1 year ago

Hi, I am new to Rails 7. When installing hail-rails on a bootstrap app rails new app --css bootstrap the generators create haml files accordingly; however, when using the tailwind option: rails new app --css tailwind The generators create html.erb files, and I have to manually convert them.

@matt17r looking at your comment, I attempted to do the same; however my tailwind.config.js differs from your example:

const defaultTheme = require('tailwindcss/defaultTheme')

module.exports = {
  content: [
    './public/*.html',
    './app/helpers/**/*.rb',
    './app/javascript/**/*.js',
    './app/views/**/*.{erb,haml,html,slim}'
  ],
  theme: {
    extend: {
      fontFamily: {
        sans: ['Inter var', ...defaultTheme.fontFamily.sans],
      },
    },
  },
  plugins: [
    require('@tailwindcss/forms'),
    require('@tailwindcss/aspect-ratio'),
    require('@tailwindcss/typography'),
  ]

Any pointers on this would be much appreciated, regards.

Jaime