From ef2ca55af1f3a90270b9db29c64cf24bc822a5c0 Mon Sep 17 00:00:00 2001 From: Daniel Bub Date: Mon, 25 Apr 2022 19:37:46 +0200 Subject: [PATCH 1/3] Add new "polling" task * Add new task to invoke tailwindcss with the polling (-p) cli option --- lib/tasks/build.rake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tasks/build.rake b/lib/tasks/build.rake index 760a478e..76906d3a 100644 --- a/lib/tasks/build.rake +++ b/lib/tasks/build.rake @@ -6,10 +6,15 @@ namespace :tailwindcss do system TAILWIND_COMPILE_COMMAND end - desc "Watch and build your Tailwind CSS on file changes" + desc "Watch and build your Tailwind CSS on file changes (using filesystem events)" task :watch do system "#{TAILWIND_COMPILE_COMMAND} -w" end + + desc "Watch and build your Tailwind CSS on file changes (using polling)" + task :poll do + system "#{TAILWIND_COMPILE_COMMAND} -p" + end end Rake::Task["assets:precompile"].enhance(["tailwindcss:build"]) From 1407827c5d4821b326c182f0f6aae9fe6dc72e09 Mon Sep 17 00:00:00 2001 From: Daniel Bub Date: Thu, 28 Apr 2022 08:55:02 +0200 Subject: [PATCH 2/3] Enable dev script to use polling * Added optional parameter "p" to enable polling * Default behavior will remain unchanged --- lib/install/Procfile.dev | 1 + lib/install/dev | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/install/Procfile.dev b/lib/install/Procfile.dev index 023e98a0..cd230fc6 100644 --- a/lib/install/Procfile.dev +++ b/lib/install/Procfile.dev @@ -1,2 +1,3 @@ web: bin/rails server -p 3000 css: bin/rails tailwindcss:watch +css_polling: bin/rails tailwindcss:poll diff --git a/lib/install/dev b/lib/install/dev index 2daf7764..a9363be2 100755 --- a/lib/install/dev +++ b/lib/install/dev @@ -6,4 +6,18 @@ then gem install foreman fi -foreman start -f Procfile.dev +while getopts p: option +do + case "${option}" + in + p)polling=1;; + *);; + esac +done + +if [ $polling -eq 1 ] +then + foreman start -f Procfile.dev -m all=1,css=0 +else + foreman start -f Procfile.dev -m all=1,css_polling=0 +fi From bd646686e1dfc446cf6c3512535dc538eecc5894 Mon Sep 17 00:00:00 2001 From: Daniel Bub Date: Fri, 29 Apr 2022 14:56:44 +0200 Subject: [PATCH 3/3] Corrected a misuse of getopts * Changed the opsstring definition --- lib/install/dev | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/install/dev b/lib/install/dev index a9363be2..b1f85435 100755 --- a/lib/install/dev +++ b/lib/install/dev @@ -6,7 +6,7 @@ then gem install foreman fi -while getopts p: option +while getopts "p" option do case "${option}" in @@ -17,6 +17,7 @@ done if [ $polling -eq 1 ] then + echo "[INFO] Enabled polling for css processing!" foreman start -f Procfile.dev -m all=1,css=0 else foreman start -f Procfile.dev -m all=1,css_polling=0