tailwindcss-rails 2.0.8 → 2.0.13

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: 455499b0b7fa6964424684bd84fddabb55a4a108b771e8d313426b8eed4206b1
4
- data.tar.gz: ddc6b66aa707db1b31179253d5916bd76b9404b545f6078642b03c1f8b97ed80
3
+ metadata.gz: 0d154c6d0679b9cbb20eb9d720cdf83f121ddbe841b0c278bcd6800b5e800610
4
+ data.tar.gz: 1364721dab0dac09481e2d07f81dbc8479bd07d676b5f249bca37477e9a25586
5
5
  SHA512:
6
- metadata.gz: ae4eb4c8a4ab5081c92c7eb45865a8613a19c9510de0d95a3bfd6f4f2bfc7b20cf0ef9878b422687615aef6d9ddb7c3661f833308a0ff8b5d6753c494f5cf1d8
7
- data.tar.gz: 0bfa67897290033712bb6c593f24c1d48d89a94708c897231e16a089ddb24e01e61a69693fdebcc2c6c3cd42f4c818111ede930643f4dbc819f48106cabffd87
6
+ metadata.gz: 91d844b8de7ca2d6b216b88cec302fd2092a7b908fd69a2c9f4f313c611c50ec44562bf0826d1118366a12061be90c34927459e8a972387088dd3502cd36a385
7
+ data.tar.gz: afa67781c4448af64cab2b6d428b3830c9622ede98d925523dedb612a9b8ec192a56abd62791730efa2c33755d394b9336cece627e4893910a33b3afd5c53cbd
data/README.md CHANGED
@@ -2,51 +2,78 @@
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
- This gem wraps [the standalone executable version](https://tailwindcss.com/blog/standalone-cli) of the Tailwind CSS 3 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.)
5
+ ## Installation
6
6
 
7
- 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.
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
8
 
9
- 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).
9
+ 1. Run `./bin/bundle add tailwindcss-rails`
10
+ 2. Run `./bin/rails tailwindcss:install`
10
11
 
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
+ 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.)
12
13
 
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.
14
14
 
15
+ ## Developing with Tailwindcss
15
16
 
16
- ## Installation
17
+ ### Configuration
17
18
 
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:
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.
19
20
 
20
- 1. Run `./bin/bundle add tailwindcss-rails`
21
- 2. Run `./bin/rails tailwindcss:install`
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).
22
22
 
23
23
 
24
- ## Building in production
24
+ ### Building for production
25
25
 
26
26
  The `tailwindcss:build` is automatically attached to `assets:precompile`, so before the asset pipeline digests the files, the Tailwind output will be generated.
27
27
 
28
- ## Building for testing
28
+
29
+ ### Building for testing
29
30
 
30
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`).
31
32
 
32
- ## Conflict with sassc-rails
33
33
 
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.
34
+ ### Update assets automatically
35
35
 
36
- ## Class names must be spelled out
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:
37
+
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.
40
+
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.
42
+
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`.
44
+
45
+
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:
47
73
 
48
74
  - arm64-darwin
49
75
  - x64-mingw32
76
+ - x64-mingw-ucrt
50
77
  - x86_64-darwin
51
78
  - x86_64-linux
52
79
  - aarch64-linux
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)
@@ -2,6 +2,7 @@ const defaultTheme = require('tailwindcss/defaultTheme')
2
2
 
3
3
  module.exports = {
4
4
  content: [
5
+ './public/*.html',
5
6
  './app/helpers/**/*.rb',
6
7
  './app/javascript/**/*.js',
7
8
  './app/views/**/*.{erb,haml,html,slim}'
@@ -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,12 +1,13 @@
1
1
  module Tailwindcss
2
2
  # constants describing the upstream tailwindcss project
3
3
  module Upstream
4
- VERSION = "v3.0.23"
4
+ VERSION = "v3.1.8"
5
5
 
6
6
  # rubygems platform name => upstream release filename
7
7
  NATIVE_PLATFORMS = {
8
8
  "arm64-darwin" => "tailwindcss-macos-arm64",
9
9
  "x64-mingw32" => "tailwindcss-windows-x64.exe",
10
+ "x64-mingw-ucrt" => "tailwindcss-windows-x64.exe",
10
11
  "x86_64-darwin" => "tailwindcss-macos-x64",
11
12
  "x86_64-linux" => "tailwindcss-linux-x64",
12
13
  "aarch64-linux" => "tailwindcss-linux-arm64",
@@ -1,3 +1,3 @@
1
1
  module Tailwindcss
2
- VERSION = "2.0.8"
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
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.8
4
+ version: 2.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-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
@@ -70,6 +70,7 @@ files:
70
70
  - lib/install/tailwind.config.js
71
71
  - lib/install/tailwindcss.rb
72
72
  - lib/tailwindcss-rails.rb
73
+ - lib/tailwindcss/commands.rb
73
74
  - lib/tailwindcss/engine.rb
74
75
  - lib/tailwindcss/upstream.rb
75
76
  - lib/tailwindcss/version.rb
@@ -97,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
98
  - !ruby/object:Gem::Version
98
99
  version: '0'
99
100
  requirements: []
100
- rubygems_version: 3.1.4
101
+ rubygems_version: 3.3.7
101
102
  signing_key:
102
103
  specification_version: 4
103
104
  summary: Integrate Tailwind CSS with the asset pipeline in Rails.