Skip to content

Commit

Permalink
Add Phlex components to Tailwind configuration
Browse files Browse the repository at this point in the history
Phlex components are Ruby files, so they have a `.rb` extension.

That's why, to be able to use Phlex components with Tailwind, we need
to add the `.rb` extension to the list of files that Tailwind should
look at when generating CSS.

This is done in the `config/tailwind.config.js`:

```js
module.exports = {
  content: [
    // ...
    './app/views/**/*.{erb,haml,html,slim,rb}'
  ]
}
```

Thanks to this commit, we automatically add the `.rb` extension to the
list of extensions when it is not already present.
  • Loading branch information
alexandreruban committed Oct 18, 2022
1 parent 3b21f0a commit 328b27f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/install/phlex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ class ApplicationView < Phlex::View
RUBY
end

tailwind_config_path = Rails.root.join("config/tailwind.config.js")

if tailwind_config_path.exist?
insert_into_file tailwind_config_path, after: "content: [" do
"\n './app/views/**/*.rb',"
end
end

say "Phlex successfully installed!"

0 comments on commit 328b27f

Please sign in to comment.