avo 4.0.0.beta.8 → 4.0.0.beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/avo/base_application_controller.rb +2 -8
- data/app/views/layouts/avo/application.html.erb +3 -0
- data/lib/avo/engine.rb +24 -1
- data/lib/avo/tailwind_builder.rb +147 -0
- data/lib/avo/version.rb +1 -1
- data/lib/avo.rb +1 -0
- data/lib/tasks/avo_tasks.rake +23 -0
- metadata +2 -6
- data/lib/generators/avo/tailwindcss/install_generator.rb +0 -110
- data/lib/generators/avo/templates/tailwindcss/Procfile.dev +0 -2
- data/lib/generators/avo/templates/tailwindcss/avo.tailwind.css +0 -13
- data/lib/generators/avo/templates/tailwindcss/tailwind.config.js +0 -5
- data/lib/tasks/tailwindcss_rails.rake +0 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d7bb9ffa2cd3c5a806ae93744aabedf20ed7bfbfc7c09b734e1973057c4c300a
|
|
4
|
+
data.tar.gz: 273595927329c2794204091e46ca6a27a567f43b3108cecad8daee853312a16e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 856ad33301d2f0856386fff262098011987bdb20ff48be5c94a887b3d11617eb23cb0d8678ce5f2c90126c2a040be804c38b8143cdd4fcfe21a022caf0d59f55
|
|
7
|
+
data.tar.gz: 3c03d9f202c4cfc0e77521fb29de67e3b21cd36040b2ea9c01b169b475a0a5f2b23551d22b8e7d840c0ee5722bdff4b67cad93b6101c87b2a579987c8e8bf7fd
|
data/Gemfile.lock
CHANGED
|
@@ -296,14 +296,8 @@ module Avo
|
|
|
296
296
|
end
|
|
297
297
|
|
|
298
298
|
def set_stylesheet_assets_path
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
# Prefer the user's tailwind config if it exists, otherwise use the default one from Avo
|
|
302
|
-
@stylesheet_assets_path = if Rails.root.join("config", "avo", "tailwind.config.js").exist?
|
|
303
|
-
"avo.tailwind"
|
|
304
|
-
else
|
|
305
|
-
"avo/application"
|
|
306
|
-
end
|
|
299
|
+
@stylesheet_assets_path = "avo/application"
|
|
300
|
+
@custom_stylesheet_path = "avo.tailwind" if Avo::TailwindBuilder.custom_build_exists?
|
|
307
301
|
end
|
|
308
302
|
|
|
309
303
|
def choose_layout
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
<%= render partial: "avo/partials/pre_head" %>
|
|
19
19
|
<%= render Avo::AssetManager::StylesheetComponent.new asset_manager: Avo.asset_manager %>
|
|
20
20
|
<%= stylesheet_link_tag @stylesheet_assets_path, "data-turbo-track": "reload", as: "style" %>
|
|
21
|
+
<% if @custom_stylesheet_path %>
|
|
22
|
+
<%= stylesheet_link_tag @custom_stylesheet_path, "data-turbo-track": "reload", as: "style" %>
|
|
23
|
+
<% end %>
|
|
21
24
|
|
|
22
25
|
<%= javascript_include_tag "avo/application", "data-turbo-track": "reload", defer: true %>
|
|
23
26
|
|
data/lib/avo/engine.rb
CHANGED
|
@@ -29,7 +29,6 @@ module Avo
|
|
|
29
29
|
isolate_namespace Avo
|
|
30
30
|
|
|
31
31
|
rake_tasks do
|
|
32
|
-
# Ensure Avo tasks are loaded
|
|
33
32
|
load File.expand_path("../tasks/avo_tasks.rake", __dir__)
|
|
34
33
|
|
|
35
34
|
if ENV["BUILD_AVO_ASSETS"] == "true"
|
|
@@ -37,6 +36,30 @@ module Avo
|
|
|
37
36
|
Rake::Task["assets:precompile"].enhance(["avo:build"])
|
|
38
37
|
end
|
|
39
38
|
end
|
|
39
|
+
|
|
40
|
+
if Avo::TailwindBuilder.tailwindcss_available? && Rake::Task.task_defined?("assets:precompile")
|
|
41
|
+
Rake::Task["assets:precompile"].enhance(["avo:tailwindcss:build"])
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
initializer "avo.tailwindcss", after: :load_config_initializers do
|
|
46
|
+
next unless Rails.env.development?
|
|
47
|
+
|
|
48
|
+
Rails.application.config.after_initialize do
|
|
49
|
+
next unless Avo::TailwindBuilder.tailwindcss_available?
|
|
50
|
+
|
|
51
|
+
begin
|
|
52
|
+
unless Avo::TailwindBuilder.build
|
|
53
|
+
Rails.logger.warn "Avo: Custom Tailwind CSS auto-build failed (run bin/rails avo:tailwindcss:build for details)."
|
|
54
|
+
end
|
|
55
|
+
rescue StandardError => e
|
|
56
|
+
Rails.logger.warn "Avo: Failed to auto-build Tailwind CSS: #{e.message}"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
unless Avo::TailwindBuilder.procfile_has_avo_tailwind_watcher?
|
|
60
|
+
Rails.logger.info "Avo: For live Tailwind CSS reload in development, add to Procfile.dev: avo_css: bin/rails avo:tailwindcss:watch"
|
|
61
|
+
end
|
|
62
|
+
end
|
|
40
63
|
end
|
|
41
64
|
|
|
42
65
|
config.after_initialize do
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
require "fileutils"
|
|
2
|
+
|
|
3
|
+
module Avo
|
|
4
|
+
class TailwindBuilder
|
|
5
|
+
def self.build
|
|
6
|
+
new.build
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.watch
|
|
10
|
+
new.watch
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.tailwindcss_available?
|
|
14
|
+
require "tailwindcss/ruby"
|
|
15
|
+
true
|
|
16
|
+
rescue LoadError
|
|
17
|
+
false
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.custom_build_exists?
|
|
21
|
+
return false unless defined?(Rails)
|
|
22
|
+
|
|
23
|
+
Rails.root.join("app", "assets", "builds", "avo.tailwind.css").exist?
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.procfile_has_avo_tailwind_watcher?
|
|
27
|
+
path = Rails.root.join("Procfile.dev")
|
|
28
|
+
return false unless path.exist?
|
|
29
|
+
|
|
30
|
+
File.read(path).include?("avo:tailwindcss")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def build
|
|
34
|
+
return true unless self.class.tailwindcss_available?
|
|
35
|
+
|
|
36
|
+
generate_input_file
|
|
37
|
+
success = run_tailwindcss("--minify")
|
|
38
|
+
log_build_failure unless success
|
|
39
|
+
success
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def watch
|
|
43
|
+
return unless self.class.tailwindcss_available?
|
|
44
|
+
|
|
45
|
+
generate_input_file
|
|
46
|
+
signature = host_avo_stylesheets_signature
|
|
47
|
+
|
|
48
|
+
pid = spawn_tailwindcss("--minify", "--watch")
|
|
49
|
+
|
|
50
|
+
begin
|
|
51
|
+
loop do
|
|
52
|
+
_, status = Process.waitpid2(pid, Process::WNOHANG)
|
|
53
|
+
break if status
|
|
54
|
+
|
|
55
|
+
new_signature = host_avo_stylesheets_signature
|
|
56
|
+
if new_signature != signature
|
|
57
|
+
signature = new_signature
|
|
58
|
+
generate_input_file
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
sleep 1
|
|
62
|
+
end
|
|
63
|
+
rescue Interrupt
|
|
64
|
+
Process.kill("TERM", pid)
|
|
65
|
+
raise
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
|
|
71
|
+
def tmp_input_dir
|
|
72
|
+
Rails.root.join("tmp", "avo")
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def input_path
|
|
76
|
+
tmp_input_dir.join("avo.tailwind.input.css")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def output_path
|
|
80
|
+
Rails.root.join("app", "assets", "builds", "avo.tailwind.css")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def generate_input_file
|
|
84
|
+
FileUtils.mkdir_p(tmp_input_dir)
|
|
85
|
+
|
|
86
|
+
lines = []
|
|
87
|
+
# Input lives under tmp/avo/; without `source("../../")` Tailwind v4 only scans near this file, so
|
|
88
|
+
# classes in app/views/**/*.erb (and the rest of the app) are never detected.
|
|
89
|
+
lines << %(@import "tailwindcss" source("../../");)
|
|
90
|
+
collect_host_avo_stylesheets.each do |path|
|
|
91
|
+
lines << %(@import "#{path}";)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
File.write(input_path, lines.join("\n") + "\n")
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def collect_host_avo_stylesheets
|
|
98
|
+
base = Rails.root.join("app", "assets", "stylesheets", "avo")
|
|
99
|
+
return [] unless Dir.exist?(base)
|
|
100
|
+
|
|
101
|
+
Dir
|
|
102
|
+
.glob(base.join("**", "*.css"))
|
|
103
|
+
.select { |path| File.file?(path) }
|
|
104
|
+
.sort
|
|
105
|
+
.map { |path| Pathname.new(path).relative_path_from(tmp_input_dir).to_s.tr("\\", "/") }
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def host_avo_stylesheets_signature
|
|
109
|
+
collect_host_avo_stylesheets.join("\n")
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def run_tailwindcss(*args)
|
|
113
|
+
require "tailwindcss/ruby"
|
|
114
|
+
|
|
115
|
+
FileUtils.mkdir_p(output_path.dirname)
|
|
116
|
+
|
|
117
|
+
Dir.chdir(Rails.root) do
|
|
118
|
+
Kernel.system(
|
|
119
|
+
Tailwindcss::Ruby.executable,
|
|
120
|
+
"-i", input_path.to_s,
|
|
121
|
+
"-o", output_path.to_s,
|
|
122
|
+
*args
|
|
123
|
+
)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def spawn_tailwindcss(*args)
|
|
128
|
+
require "tailwindcss/ruby"
|
|
129
|
+
|
|
130
|
+
FileUtils.mkdir_p(output_path.dirname)
|
|
131
|
+
|
|
132
|
+
Process.spawn(
|
|
133
|
+
Tailwindcss::Ruby.executable,
|
|
134
|
+
"-i", input_path.to_s,
|
|
135
|
+
"-o", output_path.to_s,
|
|
136
|
+
*args,
|
|
137
|
+
chdir: Rails.root.to_s
|
|
138
|
+
)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def log_build_failure
|
|
142
|
+
message = "[Avo] avo:tailwindcss build failed."
|
|
143
|
+
Rails.logger.warn(message) if defined?(Rails) && Rails.logger
|
|
144
|
+
warn message
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
data/lib/avo/version.rb
CHANGED
data/lib/avo.rb
CHANGED
data/lib/tasks/avo_tasks.rake
CHANGED
|
@@ -141,3 +141,26 @@ task "avo:yarn_install" do
|
|
|
141
141
|
puts "[Avo->] Adding yarn dependencies"
|
|
142
142
|
`yarn add tailwindcss@^4.0.0 @tailwindcss/typography@^0.5.16 @tailwindcss/container-queries@^0.1.1 --cwd #{Avo::Engine.root}`
|
|
143
143
|
end
|
|
144
|
+
|
|
145
|
+
desc "Build Avo custom Tailwind CSS"
|
|
146
|
+
task "avo:tailwindcss:build" => :environment do
|
|
147
|
+
unless Avo::TailwindBuilder.tailwindcss_available?
|
|
148
|
+
puts "[Avo->] tailwindcss-rails not found; skipping avo:tailwindcss:build"
|
|
149
|
+
next
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
puts "[Avo->] Building Avo Tailwind CSS extension (avo.tailwind)..."
|
|
153
|
+
unless Avo::TailwindBuilder.build
|
|
154
|
+
abort "[Avo->] avo:tailwindcss:build failed"
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
desc "Watch and rebuild Avo custom Tailwind CSS on changes"
|
|
159
|
+
task "avo:tailwindcss:watch" => :environment do
|
|
160
|
+
unless Avo::TailwindBuilder.tailwindcss_available?
|
|
161
|
+
abort "[Avo->] tailwindcss-rails not found; add tailwindcss-rails to your Gemfile to use avo:tailwindcss:watch"
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
puts "[Avo->] Watching Avo Tailwind CSS extension..."
|
|
165
|
+
Avo::TailwindBuilder.watch
|
|
166
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: avo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.0.beta.
|
|
4
|
+
version: 4.0.0.beta.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adrian Marin
|
|
@@ -1044,6 +1044,7 @@ files:
|
|
|
1044
1044
|
- lib/avo/services/hq_reporter.rb
|
|
1045
1045
|
- lib/avo/services/telemetry_service.rb
|
|
1046
1046
|
- lib/avo/services/uri_service.rb
|
|
1047
|
+
- lib/avo/tailwind_builder.rb
|
|
1047
1048
|
- lib/avo/test_helpers.rb
|
|
1048
1049
|
- lib/avo/tools/tool_manager.rb
|
|
1049
1050
|
- lib/avo/u_i_instance.rb
|
|
@@ -1069,7 +1070,6 @@ files:
|
|
|
1069
1070
|
- lib/generators/avo/resource_generator.rb
|
|
1070
1071
|
- lib/generators/avo/resource_tool_generator.rb
|
|
1071
1072
|
- lib/generators/avo/scope_generator.rb
|
|
1072
|
-
- lib/generators/avo/tailwindcss/install_generator.rb
|
|
1073
1073
|
- lib/generators/avo/templates/action.tt
|
|
1074
1074
|
- lib/generators/avo/templates/cards/chartkick_card.tt
|
|
1075
1075
|
- lib/generators/avo/templates/cards/chartkick_card_sample.tt
|
|
@@ -1119,9 +1119,6 @@ files:
|
|
|
1119
1119
|
- lib/generators/avo/templates/resource_tools/partial.tt
|
|
1120
1120
|
- lib/generators/avo/templates/resource_tools/resource_tool.tt
|
|
1121
1121
|
- lib/generators/avo/templates/scope.tt
|
|
1122
|
-
- lib/generators/avo/templates/tailwindcss/Procfile.dev
|
|
1123
|
-
- lib/generators/avo/templates/tailwindcss/avo.tailwind.css
|
|
1124
|
-
- lib/generators/avo/templates/tailwindcss/tailwind.config.js
|
|
1125
1122
|
- lib/generators/avo/templates/tool/controller.tt
|
|
1126
1123
|
- lib/generators/avo/templates/tool/sidebar_item.tt
|
|
1127
1124
|
- lib/generators/avo/templates/tool/view.tt
|
|
@@ -1130,7 +1127,6 @@ files:
|
|
|
1130
1127
|
- lib/generators/model_generator.rb
|
|
1131
1128
|
- lib/generators/rails/avo_resource_generator.rb
|
|
1132
1129
|
- lib/tasks/avo_tasks.rake
|
|
1133
|
-
- lib/tasks/tailwindcss_rails.rake
|
|
1134
1130
|
- public/avo-assets/avo.base.css
|
|
1135
1131
|
- public/avo-assets/avo.base.js
|
|
1136
1132
|
- public/avo-assets/avo.base.js.map
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
require_relative "../base_generator"
|
|
2
|
-
|
|
3
|
-
module Generators
|
|
4
|
-
module Avo
|
|
5
|
-
module Tailwindcss
|
|
6
|
-
class InstallGenerator < BaseGenerator
|
|
7
|
-
source_root File.expand_path("../templates", __dir__)
|
|
8
|
-
|
|
9
|
-
namespace "avo:tailwindcss:install"
|
|
10
|
-
desc "Add Tailwindcss to your Avo project."
|
|
11
|
-
|
|
12
|
-
def create_files
|
|
13
|
-
unless tailwindcss_installed?
|
|
14
|
-
say "Installing Tailwindcss"
|
|
15
|
-
system "./bin/bundle add tailwindcss-rails"
|
|
16
|
-
system "./bin/rails tailwindcss:install"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
unless (path = Rails.root.join("config", "avo", "tailwind.config.js")).exist?
|
|
20
|
-
say "Generating the Avo config file."
|
|
21
|
-
copy_file template_path("tailwind.config.js"), path
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
unless (path = Rails.root.join("app", "assets", "stylesheets", "avo" ,"avo.tailwind.css")).exist?
|
|
25
|
-
say "Add default tailwind.css"
|
|
26
|
-
copy_file template_path("avo.tailwind.css"), path
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
script_name = "avo:tailwindcss"
|
|
30
|
-
if Rails.root.join("Procfile.dev").exist?
|
|
31
|
-
say "Add #{cmd = "avo_css: yarn #{script_name} --watch"} to Procfile.dev"
|
|
32
|
-
append_to_file "Procfile.dev", "\n#{cmd}\n"
|
|
33
|
-
else
|
|
34
|
-
say "Add default Procfile.dev"
|
|
35
|
-
copy_file template_path("Procfile.dev"), "Procfile.dev"
|
|
36
|
-
|
|
37
|
-
say "Ensure foreman is installed"
|
|
38
|
-
run "gem install foreman"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
script_command = "tailwindcss -i ./app/assets/stylesheets/avo/avo.tailwind.css -o ./app/assets/builds/avo.tailwind.css -c ./config/avo/tailwind.config.js --minify"
|
|
42
|
-
pretty_script_command = "\"#{script_name}\": \"#{script_command}\""
|
|
43
|
-
|
|
44
|
-
if (path = Rails.root.join("package.json")).exist?
|
|
45
|
-
say "Add #{pretty_script_command} to package.json"
|
|
46
|
-
json_data = JSON.parse(File.read(path))
|
|
47
|
-
json_data["scripts"] ||= {}
|
|
48
|
-
json_data["scripts"][script_name] = script_command
|
|
49
|
-
|
|
50
|
-
File.open(path, 'w') do |file|
|
|
51
|
-
file.write(JSON.pretty_generate(json_data) + "\n")
|
|
52
|
-
end
|
|
53
|
-
else
|
|
54
|
-
say "package.json not found.", :yellow
|
|
55
|
-
say "Ensure you have the following script in your package.json file.", :yellow
|
|
56
|
-
say "\"scripts\": {\n" \
|
|
57
|
-
" #{pretty_script_command}\n" \
|
|
58
|
-
"}", :green
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
rake_enhance = <<~RUBY
|
|
62
|
-
|
|
63
|
-
# When running `rake assets:precompile` this is the order of events:
|
|
64
|
-
# 1 - Task `avo:yarn_install`
|
|
65
|
-
# 2 - Task `avo:sym_link`
|
|
66
|
-
# 3 - Cmd `yarn avo:tailwindcss`
|
|
67
|
-
# 4 - Task `assets:precompile`
|
|
68
|
-
Rake::Task["assets:precompile"].enhance(["avo:sym_link"])
|
|
69
|
-
Rake::Task["avo:sym_link"].enhance(["avo:yarn_install"])
|
|
70
|
-
Rake::Task["avo:sym_link"].enhance do
|
|
71
|
-
`yarn avo:tailwindcss`
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
RUBY
|
|
75
|
-
|
|
76
|
-
if (path = Rails.root.join("Rakefile")).exist?
|
|
77
|
-
say "Add #{rake_enhance.strip} to Rakefile"
|
|
78
|
-
append_to_file path, rake_enhance
|
|
79
|
-
else
|
|
80
|
-
say "Rakefile not found.", :yellow
|
|
81
|
-
say "Ensure you have the following code in your Rakefile file.", :yellow
|
|
82
|
-
say rake_enhance, :green
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
say "Make sure you run \"bundle exec rake avo:sym_link\" and \"bundle exec rake avo:yarn_install\" before compiling the assets with the \"#{script_name}\" task.", :green
|
|
86
|
-
if (path = Rails.root.join("bin", "dev")).exist?
|
|
87
|
-
lines = File.read(path).lines
|
|
88
|
-
|
|
89
|
-
# Insert the task after the shebang line (the first line)
|
|
90
|
-
shebang = lines.first
|
|
91
|
-
lines[0] = "#{shebang}\nbundle exec rake avo:sym_link\nbundle exec rake avo:yarn_install\n"
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
File.write(path, lines.join)
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
no_tasks do
|
|
99
|
-
def template_path(filename)
|
|
100
|
-
Pathname.new(__dir__).join("..", "templates", "tailwindcss", filename).to_s
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def tailwindcss_installed?
|
|
104
|
-
Rails.root.join("config", "tailwind.config.js").exist? || Rails.root.join("tailwind.config.js").exist?
|
|
105
|
-
end
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# Use the user provided asset or use the default
|
|
2
|
-
ASSET_FILE = ARGV[0] || "app/assets/builds/avo.tailwind.css" unless defined?(ASSET_FILE)
|
|
3
|
-
# Se the tailwindcss-rails package name
|
|
4
|
-
TAILWINDCSS_RAILS = "tailwindcss-rails" unless defined?(TAILWINDCSS_RAILS)
|
|
5
|
-
|
|
6
|
-
# Check if tailwindcss-rails is being used
|
|
7
|
-
if Gem.loaded_specs.key? TAILWINDCSS_RAILS
|
|
8
|
-
# Get the path
|
|
9
|
-
GEM_PATH = Gem.loaded_specs[TAILWINDCSS_RAILS].full_gem_path
|
|
10
|
-
# Compose the compile command
|
|
11
|
-
AVO_TAILWIND_COMPILE_COMMAND = "#{RbConfig.ruby} #{Pathname.new(GEM_PATH)}/exe/tailwindcss -i '#{Rails.root.join("app/assets/stylesheets/avo.tailwind.css")}' -o '#{Rails.root.join(ASSET_FILE)}' -c '#{Rails.root.join("config/tailwind.config.js")}' --minify"
|
|
12
|
-
|
|
13
|
-
namespace "avo:tailwindcss" do
|
|
14
|
-
desc "Build your Tailwind CSS"
|
|
15
|
-
task :build do
|
|
16
|
-
system(AVO_TAILWIND_COMPILE_COMMAND, exception: true)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
desc "Watch and build your Tailwind CSS on file changes"
|
|
20
|
-
task :watch do
|
|
21
|
-
system "#{AVO_TAILWIND_COMPILE_COMMAND} -w"
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|