tailwindcss-rails 2.0.12-x64-mingw-ucrt → 2.0.13-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91387d160f6875676e8d802b720520897f7c5edbae07828f61eefd870a6b14bb
4
- data.tar.gz: c7e50b2976d8d3a0819a4c2300bc7e0492f7afe2a79891dcf975bec26242b72b
3
+ metadata.gz: 95191f09a75b93b228526d1fc8150430b71f6fb577fc3d5a9a5abb2450ab1c1d
4
+ data.tar.gz: b019892df242fa9a9c0915a08ef1b17eb822b3a995e9820ed8c038b08b95d6a1
5
5
  SHA512:
6
- metadata.gz: 60eb817bda886482f3c77c14360a397b4a88ba319266ee2b79808e89b63b8031c4f943a3a6ad86202e631c056e03923861a9582155cacee83375b50805e1bb57
7
- data.tar.gz: 9f0a7a2ea037508aeaf3bc4d4a85e48936a3f1174ac33dbfbaac9b4da84fb23eec08495593d999303422ed7dc144866cd241e8d61d143ee5fd214b0e146b82b5
6
+ metadata.gz: b73f41e1dfe849c2f3c70a79d4fc15ba236fef391c76682d96daaa350bcb78f3037f1935e10653cde0ed8bdacb50e0e5f8c17df5fad3c46922bdfed912afd905
7
+ data.tar.gz: d4ae0b2e07597b5889f194c633d6d7dc3f86391f45f43f62e94a746a7088fb5cd0ca4f8b82c18069e8549c55bb90f32b88b224000b80122018b8981270ccf431
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
- When 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 either by running `rails tailwindcss:watch` as a separate process, or by running `./bin/dev` which uses [foreman](https://github.com/ddollar/foreman) to starts both the Tailwind watch process and the rails server in development mode. 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.
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
- 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:
29
+ ### Building for testing
19
30
 
20
- 1. Run `./bin/bundle add tailwindcss-rails`
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
- ## Building in production
34
+ ### Update assets automatically
25
35
 
26
- The `tailwindcss:build` is automatically attached to `assets:precompile`, so before the asset pipeline digests the files, the Tailwind output will be generated.
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
- ## Building for testing
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
- 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`).
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
- ## Conflict with sassc-rails
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
- ## Class names must be spelled out
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 "shellwords"
5
- require "tailwindcss/upstream"
6
-
7
- supported_platforms = Tailwindcss::Upstream::NATIVE_PLATFORMS.keys
8
- platform = [:cpu, :os].map { |m| Gem::Platform.local.send(m) }.join("-")
9
-
10
- if supported_platforms.none? { |supported_platform| Gem::Platform.match(supported_platform) }
11
- STDERR.puts(<<~ERRMSG)
12
- ERROR: tailwindcss-rails does not support the #{platform} platform
13
- Please install tailwindcss following instructions at https://tailwindcss.com/docs/installation
14
- ERRMSG
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
@@ -1,3 +1,3 @@
1
1
  module Tailwindcss
2
- VERSION = "2.0.12"
2
+ VERSION = "2.0.13"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  module Tailwindcss
2
2
  end
3
3
 
4
- require "tailwindcss/upstream"
5
- require "tailwindcss/version"
6
- require "tailwindcss/engine"
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
- system(TAILWIND_COMPILE_COMMAND, exception: true)
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
- system "#{TAILWIND_COMPILE_COMMAND} -w"
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.12
4
+ version: 2.0.13
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-10 00:00:00.000000000 Z
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.19
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: []