Skip to content

Commit 7c66884

Browse files
bopmflavorjones
andauthored
Fix read-only file system issue (#556)
* Fix read-only file system issue * Changes due to review * Restore original formatting * Changes due to review * Remove new line * Clarify "engines" rake task description --------- Co-authored-by: Mike Dalessio <mike@37signals.com>
1 parent dfa066d commit 7c66884

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ If you need to use a custom input or output file, you can run `bundle exec tailw
392392
393393
_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)._
394394
395-
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.
395+
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.
396396
397397
> [!IMPORTANT]
398398
> 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.

lib/tailwindcss/engine.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,5 @@ class Engine < ::Rails::Engine
1515
config.app_generators do |g|
1616
g.template_engine :tailwindcss
1717
end
18-
19-
config.after_initialize do
20-
Tailwindcss::Engines.bundle
21-
end
2218
end
2319
end

lib/tasks/build.rake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace :tailwindcss do
22
desc "Build your Tailwind CSS"
3-
task build: :environment do |_, args|
3+
task build: [:environment, :engines] do |_, args|
44
debug = args.extras.include?("debug")
55
verbose = args.extras.include?("verbose")
66

@@ -12,7 +12,7 @@ namespace :tailwindcss do
1212
end
1313

1414
desc "Watch and build your Tailwind CSS on file changes"
15-
task watch: :environment do |_, args|
15+
task watch: [:environment, :engines] do |_, args|
1616
debug = args.extras.include?("debug")
1717
poll = args.extras.include?("poll")
1818
always = args.extras.include?("always")
@@ -26,6 +26,11 @@ namespace :tailwindcss do
2626
rescue Interrupt
2727
puts "Received interrupt, exiting tailwindcss:watch" if args.extras.include?("verbose")
2828
end
29+
30+
desc "Create Tailwind CSS entry point files for Rails Engines"
31+
task engines: :environment do
32+
Tailwindcss::Engines.bundle
33+
end
2934
end
3035

3136
Rake::Task["assets:precompile"].enhance(["tailwindcss:build"])

0 commit comments

Comments
 (0)