tailwindcss-rails 2.0.12-x64-mingw32 → 2.0.13-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -14
- data/exe/tailwindcss +14 -41
- data/lib/tailwindcss/commands.rb +77 -0
- data/lib/tailwindcss/version.rb +1 -1
- data/lib/tailwindcss-rails.rb +4 -3
- data/lib/tasks/build.rake +11 -6
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15228d038b044c9c5f47bc70cf8d5c7606672aae8c48d779558591a1b8f4f911
|
4
|
+
data.tar.gz: 71cc8cb09efa68819f4985eb9116a1243d1b53d55ff63f7c4cf87155c5fad72b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e8fb698037e47fd448bd5fc432df6dc1bb423667ff2e262f673cabe2870d430ef66e745c7efe9b4ee52e4aa15fb707a2b6438f5ddf6f232f8e03166000df1df
|
7
|
+
data.tar.gz: 81c663f0669f79bc6032eff1c489839a6d659e92dd338d86fdb71d4cbd2501a5635a3a134aa93be11544bc9b7634a62fd51ed668c80ce17a72a7f94459d7b82a
|
data/README.md
CHANGED
@@ -2,45 +2,71 @@
|
|
2
2
|
|
3
3
|
[Tailwind CSS](https://tailwindcss.com) is a utility-first CSS framework packed with classes like flex, pt-4, text-center and rotate-90 that can be composed to build any design, directly in your markup.
|
4
4
|
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
With Rails 7 you can generate a new application preconfigured with Tailwind by using `--css tailwind`. If you're adding Tailwind later, you need to:
|
8
|
+
|
9
|
+
1. Run `./bin/bundle add tailwindcss-rails`
|
10
|
+
2. Run `./bin/rails tailwindcss:install`
|
11
|
+
|
5
12
|
This gem wraps [the standalone executable version](https://tailwindcss.com/blog/standalone-cli) of the Tailwind CSS v3 framework. These executables are platform specific, so there are actually separate underlying gems per platform, but the correct gem will automatically be picked for your platform. Supported platforms are Linux x64, macOS arm64, macOS x64, and Windows x64. (Note that due to this setup, you must install the actual gems – you can't pin your gem to the github repo.)
|
6
13
|
|
14
|
+
|
15
|
+
## Developing with Tailwindcss
|
16
|
+
|
17
|
+
### Configuration
|
18
|
+
|
7
19
|
You can customize the Tailwind build through the `config/tailwind.config.js` file, just like you would if Tailwind was running in a traditional node installation. All the first-party plugins are supported.
|
8
20
|
|
9
21
|
The installer will create your Tailwind input file in `app/assets/stylesheets/application.tailwind.css`. This is where you import the plugins you want to use, and where you can setup your custom `@apply` rules. When you run `rails tailwindcss:build`, this input file will be used to generate the output in `app/assets/builds/tailwind.css`. That's the output CSS that you'll include in your app (the installer automatically configures this, alongside the Inter font as well).
|
10
22
|
|
11
|
-
If you need to use a custom input or output file, you can run `bundle exec tailwindcss` to access the platform-specific executable, and give it your own build options.
|
12
23
|
|
13
|
-
|
24
|
+
### Building for production
|
14
25
|
|
26
|
+
The `tailwindcss:build` is automatically attached to `assets:precompile`, so before the asset pipeline digests the files, the Tailwind output will be generated.
|
15
27
|
|
16
|
-
## Installation
|
17
28
|
|
18
|
-
|
29
|
+
### Building for testing
|
19
30
|
|
20
|
-
|
21
|
-
2. Run `./bin/rails tailwindcss:install`
|
31
|
+
The `tailwindcss:build` is automatically attached to `test:prepare`, which runs before Rails tests. (Note that this currently only applies to rails `test:*` tasks (like `test:all` or `test:controllers`), not "rails test", as that doesn't load `test:prepare`).
|
22
32
|
|
23
33
|
|
24
|
-
|
34
|
+
### Update assets automatically
|
25
35
|
|
26
|
-
|
36
|
+
While you're developing your application, you want to run Tailwind in "watch" mode, so changes are automatically reflected in the generated CSS output. You can do this by:
|
27
37
|
|
28
|
-
|
38
|
+
- running `rails tailwindcss:watch` as a separate process,
|
39
|
+
- or by running `./bin/dev` which uses [foreman](https://github.com/ddollar/foreman) to start both the Tailwind watch process and the rails server in development mode.
|
29
40
|
|
30
|
-
|
41
|
+
If you are running `rails tailwindcss:watch` as a process in a Docker container, set `tty: true` in `docker-compose.yml` for the appropriate container to keep the watch process running.
|
31
42
|
|
32
|
-
|
43
|
+
If you are running `rails tailwindcss:watch` on a system that doesn't fully support file system events, pass a `poll` argument to the task to instruct tailwindcss to instead use polling: `rails tailwindcss:watch[poll]`. If you use `bin/dev` then you should modify your `Procfile.dev`.
|
33
44
|
|
34
|
-
Tailwind uses modern CSS features that are not recognized by the `sassc-rails` extension that was included by default in the Gemfile for Rails 6. In order to avoid any errors like `SassC::SyntaxError`, you must remove that gem from your Gemfile.
|
35
45
|
|
36
|
-
|
46
|
+
### Debugging with unminified assets
|
47
|
+
|
48
|
+
If you want unminified assets, you can pass a `debug` argument to the rake task, i.e. `rails tailwindcss:build[debug]` or `rails tailwindcss:watch[debug]`.
|
49
|
+
|
50
|
+
Note that you can combine task options, e.g. `rails tailwindcss:watch[debug,poll]`.
|
51
|
+
|
52
|
+
|
53
|
+
### Custom inputs or outputs
|
54
|
+
|
55
|
+
If you need to use a custom input or output file, you can run `bundle exec tailwindcss` to access the platform-specific executable, and give it your own build options.
|
37
56
|
|
38
|
-
For Tailwind to work, your class names need to be spelled out. They can't be programmatically composed. So no "text-gray-#{grade}", only "text-gray-500".
|
39
57
|
|
40
58
|
## Troubleshooting
|
41
59
|
|
42
60
|
Some common problems experienced by users ...
|
43
61
|
|
62
|
+
### Conflict with sassc-rails
|
63
|
+
|
64
|
+
Tailwind uses modern CSS features that are not recognized by the `sassc-rails` extension that was included by default in the Gemfile for Rails 6. In order to avoid any errors like `SassC::SyntaxError`, you must remove that gem from your Gemfile.
|
65
|
+
|
66
|
+
### Class names must be spelled out
|
67
|
+
|
68
|
+
For Tailwind to work, your class names need to be spelled out. They can't be programmatically composed. So no "text-gray-#{grade}", only "text-gray-500".
|
69
|
+
|
44
70
|
### ERROR: Cannot find the tailwindcss executable for <supported platform>
|
45
71
|
|
46
72
|
Some users are reporting this error even when running on one of the supported native platforms:
|
data/exe/tailwindcss
CHANGED
@@ -1,46 +1,19 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
# because rubygems shims assume a gem's executables are Ruby
|
3
3
|
|
4
|
-
require "
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
4
|
+
require "tailwindcss/commands"
|
5
|
+
|
6
|
+
begin
|
7
|
+
command = [Tailwindcss::Commands.executable, *ARGV]
|
8
|
+
puts command.inspect
|
9
|
+
if Gem.win_platform?
|
10
|
+
# use system rather than exec as exec inexplicably fails to find the executable on Windows
|
11
|
+
# see related https://github.com/rubys/sprockets-esbuild/pull/4
|
12
|
+
system(*command, exception: true)
|
13
|
+
else
|
14
|
+
exec(*command)
|
15
|
+
end
|
16
|
+
rescue Tailwindcss::Commands::UnsupportedPlatformException, Tailwindcss::Commands::ExecutableNotFoundException => e
|
17
|
+
STDERR.puts("ERROR: " + e.message)
|
15
18
|
exit 1
|
16
19
|
end
|
17
|
-
|
18
|
-
exe_path = Dir.glob(File.join(__dir__, "*", "tailwindcss")).find do |f|
|
19
|
-
Gem::Platform.match(File.basename(File.dirname(f)))
|
20
|
-
end
|
21
|
-
if exe_path.nil?
|
22
|
-
STDERR.puts(<<~ERRMSG)
|
23
|
-
ERROR: Cannot find the tailwindcss executable for #{platform} in #{__dir__}
|
24
|
-
If you're using bundler, please make sure you're on the latest bundler version:
|
25
|
-
|
26
|
-
gem install bundler
|
27
|
-
bundle update --bundler
|
28
|
-
|
29
|
-
Then make sure your lock file includes this platform by running:
|
30
|
-
|
31
|
-
bundle lock --add-platform #{platform}
|
32
|
-
bundle install
|
33
|
-
|
34
|
-
See `bundle lock --help` output for details.
|
35
|
-
|
36
|
-
If you're still seeing this message after taking those steps, try running
|
37
|
-
`bundle config` and ensure `force_ruby_platform` isn't set to `true`. See
|
38
|
-
https://github.com/rails/tailwindcss-rails#check-bundle_force_ruby_platform
|
39
|
-
for more details.
|
40
|
-
ERRMSG
|
41
|
-
exit 1
|
42
|
-
end
|
43
|
-
|
44
|
-
command = Shellwords.join([exe_path, ARGV].flatten)
|
45
|
-
puts "+ #{command}"
|
46
|
-
exec(command)
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require_relative "upstream"
|
2
|
+
|
3
|
+
module Tailwindcss
|
4
|
+
module Commands
|
5
|
+
# raised when the host platform is not supported by upstream tailwindcss's binary releases
|
6
|
+
class UnsupportedPlatformException < StandardError
|
7
|
+
end
|
8
|
+
|
9
|
+
# raised when the tailwindcss executable could not be found where we expected it to be
|
10
|
+
class ExecutableNotFoundException < StandardError
|
11
|
+
end
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def platform
|
15
|
+
[:cpu, :os].map { |m| Gem::Platform.local.send(m) }.join("-")
|
16
|
+
end
|
17
|
+
|
18
|
+
def executable(
|
19
|
+
exe_path: File.expand_path(File.join(__dir__, "..", "..", "exe"))
|
20
|
+
)
|
21
|
+
if Tailwindcss::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match(p) }
|
22
|
+
raise UnsupportedPlatformException, <<~MESSAGE
|
23
|
+
tailwindcss-rails does not support the #{platform} platform
|
24
|
+
Please install tailwindcss following instructions at https://tailwindcss.com/docs/installation
|
25
|
+
MESSAGE
|
26
|
+
end
|
27
|
+
|
28
|
+
exe_path = Dir.glob(File.expand_path(File.join(exe_path, "*", "tailwindcss"))).find do |f|
|
29
|
+
Gem::Platform.match(File.basename(File.dirname(f)))
|
30
|
+
end
|
31
|
+
|
32
|
+
if exe_path.nil?
|
33
|
+
raise ExecutableNotFoundException, <<~MESSAGE
|
34
|
+
Cannot find the tailwindcss executable for #{platform} in #{exe_path}
|
35
|
+
|
36
|
+
If you're using bundler, please make sure you're on the latest bundler version:
|
37
|
+
|
38
|
+
gem install bundler
|
39
|
+
bundle update --bundler
|
40
|
+
|
41
|
+
Then make sure your lock file includes this platform by running:
|
42
|
+
|
43
|
+
bundle lock --add-platform #{platform}
|
44
|
+
bundle install
|
45
|
+
|
46
|
+
See `bundle lock --help` output for details.
|
47
|
+
|
48
|
+
If you're still seeing this message after taking those steps, try running
|
49
|
+
`bundle config` and ensure `force_ruby_platform` isn't set to `true`. See
|
50
|
+
https://github.com/rails/tailwindcss-rails#check-bundle_force_ruby_platform
|
51
|
+
for more details.
|
52
|
+
MESSAGE
|
53
|
+
end
|
54
|
+
|
55
|
+
exe_path
|
56
|
+
end
|
57
|
+
|
58
|
+
def compile_command(debug: false, **kwargs)
|
59
|
+
[
|
60
|
+
executable(**kwargs),
|
61
|
+
"-i", Rails.root.join("app/assets/stylesheets/application.tailwind.css").to_s,
|
62
|
+
"-o", Rails.root.join("app/assets/builds/tailwind.css").to_s,
|
63
|
+
"-c", Rails.root.join("config/tailwind.config.js").to_s,
|
64
|
+
].tap do |command|
|
65
|
+
command << "--minify" unless debug
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def watch_command(poll: false, **kwargs)
|
70
|
+
compile_command(**kwargs).tap do |command|
|
71
|
+
command << "-w"
|
72
|
+
command << "-p" if poll
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
data/lib/tailwindcss/version.rb
CHANGED
data/lib/tailwindcss-rails.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Tailwindcss
|
2
2
|
end
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
require_relative "tailwindcss/upstream"
|
5
|
+
require_relative "tailwindcss/version"
|
6
|
+
require_relative "tailwindcss/engine"
|
7
|
+
require_relative "tailwindcss/commands"
|
data/lib/tasks/build.rake
CHANGED
@@ -1,14 +1,19 @@
|
|
1
|
-
TAILWIND_COMPILE_COMMAND = "#{RbConfig.ruby} #{Pathname.new(__dir__).to_s}/../../exe/tailwindcss -i '#{Rails.root.join("app/assets/stylesheets/application.tailwind.css")}' -o '#{Rails.root.join("app/assets/builds/tailwind.css")}' -c '#{Rails.root.join("config/tailwind.config.js")}' --minify"
|
2
|
-
|
3
1
|
namespace :tailwindcss do
|
4
2
|
desc "Build your Tailwind CSS"
|
5
|
-
task :build do
|
6
|
-
|
3
|
+
task :build do |_, args|
|
4
|
+
debug = args.extras.include?("debug")
|
5
|
+
command = Tailwindcss::Commands.compile_command(debug: debug)
|
6
|
+
puts command.inspect
|
7
|
+
system(*command, exception: true)
|
7
8
|
end
|
8
9
|
|
9
10
|
desc "Watch and build your Tailwind CSS on file changes"
|
10
|
-
task :watch do
|
11
|
-
|
11
|
+
task :watch do |_, args|
|
12
|
+
debug = args.extras.include?("debug")
|
13
|
+
poll = args.extras.include?("poll")
|
14
|
+
command = Tailwindcss::Commands.watch_command(debug: debug, poll: poll)
|
15
|
+
puts command.inspect
|
16
|
+
system(*command)
|
12
17
|
end
|
13
18
|
end
|
14
19
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailwindcss-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.13
|
5
5
|
platform: x64-mingw32
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 6.0.0
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email: david@loudthinking.com
|
29
29
|
executables:
|
30
30
|
- tailwindcss
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/install/tailwind.config.js
|
73
73
|
- lib/install/tailwindcss.rb
|
74
74
|
- lib/tailwindcss-rails.rb
|
75
|
+
- lib/tailwindcss/commands.rb
|
75
76
|
- lib/tailwindcss/engine.rb
|
76
77
|
- lib/tailwindcss/upstream.rb
|
77
78
|
- lib/tailwindcss/version.rb
|
@@ -84,7 +85,7 @@ licenses:
|
|
84
85
|
metadata:
|
85
86
|
homepage_uri: https://github.com/rails/tailwindcss-rails
|
86
87
|
rubygems_mfa_required: 'true'
|
87
|
-
post_install_message:
|
88
|
+
post_install_message:
|
88
89
|
rdoc_options: []
|
89
90
|
require_paths:
|
90
91
|
- lib
|
@@ -99,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
100
|
- !ruby/object:Gem::Version
|
100
101
|
version: '0'
|
101
102
|
requirements: []
|
102
|
-
rubygems_version: 3.3.
|
103
|
-
signing_key:
|
103
|
+
rubygems_version: 3.3.7
|
104
|
+
signing_key:
|
104
105
|
specification_version: 4
|
105
106
|
summary: Integrate Tailwind CSS with the asset pipeline in Rails.
|
106
107
|
test_files: []
|