Skip to content

Commit

Permalink
Tailwind configurations for running into engine
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscoLegrand committed Oct 22, 2024
1 parent 0042e85 commit 91b155a
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ PATH
specs:
oodle (0.1.0)
rails (>= 6.0.0, < 8.0.0)
tailwindcss-rails
view_component

GEM
Expand Down Expand Up @@ -215,6 +216,10 @@ GEM
securerandom (0.3.1)
sqlite3 (2.1.0-x86_64-linux-gnu)
stringio (3.1.1)
tailwindcss-rails (3.0.0)
railties (>= 7.0.0)
tailwindcss-ruby
tailwindcss-ruby (3.4.14-x86_64-linux)
thor (1.3.2)
timeout (0.4.1)
tzinfo (2.0.6)
Expand Down
1 change: 1 addition & 0 deletions app/assets/builds/oodle.css

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions app/assets/config/oodle_manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//= link_tree ../builds/ .css
//= link oodle/application.css
//= link oodle/application.tailwind.css
23 changes: 23 additions & 0 deletions config/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const defaultTheme = require('tailwindcss/defaultTheme')

module.exports = {
content: [
'./public/*.html',
'./app/helpers/**/*.rb',
'./app/javascript/**/*.js',
'./app/views/**/*.{erb,haml,html,slim}',
'./app/components/**/*.{html,erb,rb}'
],
theme: {
extend: {
fontFamily: {
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
},
},
},
plugins: [
require('@tailwindcss/forms'),
require('@tailwindcss/aspect-ratio'),
require('@tailwindcss/typography'),
]
}
11 changes: 11 additions & 0 deletions lib/oodle.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
require "oodle/version"
require "oodle/engine"

require "tailwindcss-rails"
require "view_component"
module Oodle
class Engine < ::Rails::Engine
isolate_namespace(Oodle)

initializer :append_migrations do |app|
unless app.root.to_s.match?(root.to_s + File::SEPARATOR)
app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded)
end
end
initializer "oodle.assets" do |app|
app.config.assets.precompile += %w[oodle_manifest]
end
end
end
6 changes: 0 additions & 6 deletions lib/oodle/engine.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
module Oodle
class Engine < ::Rails::Engine
isolate_namespace Oodle

initializer :append_migrations do |app|
unless app.root.to_s.match?(root.to_s + File::SEPARATOR)
app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded)
end
end
end
end
5 changes: 5 additions & 0 deletions lib/tasks/oodle_tasks.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
# task :oodle do
# # Task goes here
# end
task :tailwind_engine_watch do
system "bin/rails tailwindcss:watch -i #{Oodle::Engine.root.join("app/assets/stylesheets/application.tailwind.css")} \
-o #{Oodle::Engine.root.join("app/assets/builds/oodle.css")} \
-c #{Oodle::Engine.root.join("config/tailwind.config.js")}"
end
2 changes: 2 additions & 0 deletions oodle.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ Gem::Specification.new do |spec|
end

spec.add_dependency "rails", ">= 6.0.0", "< 8.0.0"
spec.add_dependency "tailwindcss-rails"

spec.add_dependency "view_component"
end

0 comments on commit 91b155a

Please sign in to comment.