Skip to content

Fix read-only file system issue #556

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

Merged
merged 6 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ If you need to use a custom input or output file, you can run `bundle exec tailw

_This feature is experimental and may change in the future. If you have feedback, please join the [discussion](https://github.com/rails/tailwindcss-rails/discussions/355)._

If you have Rails Engines in your application that use Tailwind CSS and provide an `app/assets/tailwind/<engine_name>/engine.css` file, entry point files will be created for each of them in `app/assets/builds/tailwind/<engine_name>.css` so they can be included in your host application's Tailwind CSS by adding `@import "../builds/tailwind/<engine_name>"` to your `app/assets/tailwind/application.css` file.
If you have Rails Engines in your application that use Tailwind CSS and provide an `app/assets/tailwind/<engine_name>/engine.css` file, entry point files will be created for each of them in `app/assets/builds/tailwind/<engine_name>.css` on the first build/watch invocation or manual call for `rails tailwindcss:engines` so they can be included in your host application's Tailwind CSS by adding `@import "../builds/tailwind/<engine_name>"` to your `app/assets/tailwind/application.css` file.

> [!IMPORTANT]
> You must `@import` the engine CSS files in your `app/assets/tailwind/application.css` for the engine to be included in the build. By default, no engine CSS files are imported, and you must opt-in to using the file in your build.
Expand Down
4 changes: 0 additions & 4 deletions lib/tailwindcss/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,5 @@ class Engine < ::Rails::Engine
config.app_generators do |g|
g.template_engine :tailwindcss
end

config.after_initialize do
Tailwindcss::Engines.bundle
end
end
end
9 changes: 7 additions & 2 deletions lib/tasks/build.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace :tailwindcss do
desc "Build your Tailwind CSS"
task build: :environment do |_, args|
task build: [:environment, :engines] do |_, args|
debug = args.extras.include?("debug")
verbose = args.extras.include?("verbose")

Expand All @@ -12,7 +12,7 @@ namespace :tailwindcss do
end

desc "Watch and build your Tailwind CSS on file changes"
task watch: :environment do |_, args|
task watch: [:environment, :engines] do |_, args|
debug = args.extras.include?("debug")
poll = args.extras.include?("poll")
always = args.extras.include?("always")
Expand All @@ -26,6 +26,11 @@ namespace :tailwindcss do
rescue Interrupt
puts "Received interrupt, exiting tailwindcss:watch" if args.extras.include?("verbose")
end

desc "Create Tailwind CSS entry point files for Rails Engines"
task engines: :environment do
Tailwindcss::Engines.bundle
end
end

Rake::Task["assets:precompile"].enhance(["tailwindcss:build"])
Expand Down
Loading