jekyll-tailwindcss 0.5.0 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9492cf16b8cad5f3df51dcfdd261be6be8e32924607dc589d0edeae0bc6f13da
4
- data.tar.gz: d3937dbfa2fa5fd19cd1fbe6054228496c2534607c3944e7eb3216e6815c73cb
3
+ metadata.gz: a81e85a7737089b5d8d581d0b3a2a57537246b0d9f2d959621c88947256e4655
4
+ data.tar.gz: 1dc39f0ac56a400201336c993a933a016c48c055620d85a1110da61af0d96626
5
5
  SHA512:
6
- metadata.gz: c0f7f4ab399b48b20094fd93ef318f4601c30e24547b7e2154720d1c5f1a34efe8c693dc9087babcafdd428f0d1017200a85c376527ea64a0d6ba4d7dcc995c5
7
- data.tar.gz: cd1594db42c22df32a69da50557fc767c01bb4ce21f9c1f0755ab120bf29c0bc7cc38286996b5b6dcd9077f82aa0da1883301457559fb039dda462dcd71fb261
6
+ metadata.gz: aa46bc05d461559f837ba25efdb96e6929aee69d3157026472e1b7d3e658a7bd68416d8f35543ae91006904fd6dce531929a72e4adf35e37bfde0ad94a40c20e
7
+ data.tar.gz: 4c15e84ccc7e25289835ad5aaf97460a0bd6973e1496df67be670b21c2c97861973222c9e6f60cc539864da6ce4a42264d3864ed5d8cc4feb33c9ce5aa63cb25
data/README.md CHANGED
@@ -2,36 +2,66 @@
2
2
 
3
3
  Bring the fun of building with TailwindCSS into your Jekyll project (without any JavaScript)
4
4
 
5
- **TL;DR** This gem borrows *heavily* from [tailwindcss-rails](https://github.com/rails/tailwindcss-rails) to provide platform-specific tailwind executables and provide a smooth developer experience in Jekyll projects
5
+ **TL;DR** This gem borrows _heavily_ from [tailwindcss-rails](https://github.com/rails/tailwindcss-rails) to provide platform-specific tailwind executables and provide a smooth developer experience in Jekyll projects
6
6
 
7
- > Because building a great jekyll site shouldnt require a `node_modules` folder
7
+ > _"Because building a great jekyll site shouldn't require a `node_modules` folder"_
8
8
 
9
9
  ## Installation
10
10
 
11
11
  Install the gem in your jekyll project's Gemfile by executing the following:
12
12
 
13
13
  ```
14
- bundle add jekyll-tailwindcss
14
+ bundle add jekyll-tailwindcss --group jekyll_plugins
15
15
  ```
16
16
 
17
- Add the plugin to your list of jekyll plugins in `_config.yml`
17
+ Or by adding the gem manually
18
18
 
19
- ```yml
20
- plugins:
21
- - jekyll-tailwindcss
19
+ ```ruby
20
+ # Gemfile
21
+ # ...
22
+ group :jekyll_plugins do
23
+ # ...
24
+ gem "jekyll-tailwindcss"
25
+ end
22
26
  ```
23
27
 
24
- ## Tailwind Configuration
28
+ > [!NOTE]
29
+ > By adding this gem to the jekyll_plugins group, you don't need to explicitly configure it in `_config.yml`.
25
30
 
26
- This plugin requires you to have a tailwind configuration file (`tailwind.config.js`) at the root level of your project, which can be generated by running:
31
+ ### Choosing a specific version of tailwindcss
27
32
 
33
+ This gem uses the latest TailwindCSS by default. However since CLI versions are managed by the `tailwindcss-ruby` gem, it supports older versions as well.
34
+
35
+ You can use an older Tailwind version by specifying it in your Gemfile:
36
+
37
+ ```ruby
38
+ # Gemfile
39
+ # ...
40
+ group :jekyll_plugins do
41
+ # ...
42
+ gem "jekyll-tailwindcss"
43
+ end
44
+ # gem versions track against tailwind releases
45
+ gem "tailwindcss-ruby", "~> 3.4"
28
46
  ```
29
- bundle exec jekyll-tailwindcss init
47
+
48
+ <details>
49
+
50
+ <summary>Tailwind Version 3 Setup</summary>
51
+
52
+ Tailwind V3 required a tailwind configuration file (`tailwind.config.js`), which needs to be specified in `_config.yml`:
53
+
54
+ ```yaml
55
+ tailwindcss:
56
+ config: "./tailwind.config.js"
30
57
  ```
31
58
 
32
- Tailwind will include the CSS for the classes found in `content` directories. For most jekyll sites, this would work well.
59
+ Tailwind will generate CSS for the classes found in `content` directories. For most jekyll sites, this would work well.
33
60
 
34
61
  ```js
62
+ // ./tailwind.config.js
63
+ /** @type {import('tailwindcss').Config} */
64
+ module.exports = {
35
65
  content: [
36
66
  "./_drafts/**/*.md",
37
67
  "./_includes/**/*.html",
@@ -40,35 +70,72 @@ Tailwind will include the CSS for the classes found in `content` directories. Fo
40
70
  "./_posts/*.md",
41
71
  "./*.{html,md}",
42
72
  ],
73
+ // ...
74
+ };
43
75
  ```
44
76
 
45
- Learn more at https://tailwindcss.com/docs/configuration
77
+ Learn more at https://v3.tailwindcss.com/docs/configuration
46
78
 
79
+ ## Example CSS
47
80
 
81
+ Any CSS file with frontmatter and `@tailwind` directives will be converted.
48
82
 
49
- ## Usage
83
+ ```css
84
+ /* assets/css/styles.css */
85
+ ---
86
+ # This yaml frontmatter is required for jekyll to process the file
87
+ ---
50
88
 
51
- ```sh
52
- bundle exec jekyll serve # or build
89
+ @tailwind base;
90
+ @tailwind components;
91
+ @tailwind utilities;
92
+
93
+ .btn {
94
+ @apply font-bold py-2 px-4 rounded !important;
95
+ }
53
96
  ```
54
97
 
55
- Any `*.css` file processed by jekyll [^1] that contains the `@tailwind` [directive](https://tailwindcss.com/docs/functions-and-directives#config) will now be converted through the Tailwind CLI.
98
+ will be converted to
56
99
 
57
- [^1]: Jekyll will process any file that begins with yaml [frontmatter](https://jekyllrb.com/docs/front-matter/)
100
+ ```css
101
+ /* _site/assets/css/styles.css */
58
102
 
59
- ### Configuration
103
+ /*
104
+ * Tailwind generated CSS
105
+ * ...
106
+ */
107
+ ```
108
+
109
+ ### PostCSS Support
60
110
 
61
- Location of the `tailwind.config.js` file can be configured in `_config.yml`:
111
+ This gem includes basic PostCSS support. If a `postcss.config.js` file is included in your `_config.yml`, the Tailwind CLI will be invoked with the `--postcss` flag.
62
112
 
63
- ``` yaml
113
+ ```yaml
64
114
  tailwindcss:
65
- config: './tailwind.config.js' # this is the default location
115
+ config: "./tailwind.config.js" # this is the default location
116
+ postcss: "./postcss.config.js" # OPTIONAL, only if you have a postcss config file
117
+ ```
118
+
119
+ > [!NOTE]
120
+ > PostCSS configuration is considered an advanced use case and is outside the scope of this gem. Users should verify their PostCSS setup outside this gem by running:
121
+ > `bundle exec tailwindcss --postcss postcss.config.js`
122
+
123
+ </details>
124
+
125
+ ## Usage
126
+
127
+ ```sh
128
+ bundle exec jekyll serve # or build
66
129
  ```
67
130
 
68
- ### Examples
131
+ Any `*.css` file processed by jekyll [^1] that contains the `@import "tailwindcss";` [directive](https://tailwindcss.com/docs/functions-and-directives#config) will be converted through the Tailwind CLI.
132
+
133
+ [^1]: Jekyll will process any file that begins with yaml [frontmatter](https://jekyllrb.com/docs/front-matter/)
69
134
 
135
+ ### Example
136
+ Any CSS file with frontmatter and `@import "tailwindcss";` will be converted.
70
137
 
71
- A CSS file with frontmatter and `@tailwind` directives:
138
+ Your CSS file
72
139
 
73
140
  ```css
74
141
  /* assets/css/styles.css */
@@ -76,12 +143,10 @@ A CSS file with frontmatter and `@tailwind` directives:
76
143
  # This yaml frontmatter is required for jekyll to process the file
77
144
  ---
78
145
 
79
- @tailwind base;
80
- @tailwind components;
81
- @tailwind utilities;
146
+ @import "tailwindcss";
82
147
 
83
148
  .btn {
84
- @apply font-bold py-2 px-4 rounded !important;
149
+ @apply rounded border border-gray-300;
85
150
  }
86
151
  ```
87
152
 
@@ -92,13 +157,24 @@ will be converted to
92
157
 
93
158
  /*
94
159
  * Tailwind generated CSS
160
+ * ...
161
+ .btn {
162
+ border-radius: 0.25rem;
163
+ border-style: var(--tw-border-style);
164
+ border-width: 1px;
165
+ border-color: var(--color-gray-300);
166
+ }
95
167
  * ...
96
168
  */
97
169
  ```
98
170
 
171
+ ### Minification
172
+
173
+ The `--minify` flag is automatically added when the `JEKYLL_ENV` environment variable is present and set to anything other than `development`. [Jekyll Docs](https://jekyllrb.com/docs/configuration/environments/)
174
+
99
175
  ## Development
100
176
 
101
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
177
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
102
178
 
103
179
  To install this gem on your local machine, run `bundle exec rake install`.
104
180
 
@@ -110,12 +186,15 @@ The unit tests are run with `bundle exec rspec`
110
186
 
111
187
  ### Testing in a Jekyll project
112
188
 
113
- If you want to test modifications to this gem, you must run `rake download` once to download the upstream `tailwindcss` executables.
189
+ If you want to test modifications to this gem, you can point your Jekyll project's `Gemfile` at the local version of the gem as you normally would:
114
190
 
115
- Then you can point your Jekyll project's `Gemfile` at the local version of the gem as you normally would:
116
-
117
- ``` ruby
118
- gem "jekyll-tailwindcss", path: "/path/to/jekyll-tailwindcss"
191
+ ```ruby
192
+ # Gemfile
193
+ # ...
194
+ group :jekyll_plugins do
195
+ # ...
196
+ gem "jekyll-tailwindcss", path: "/path/to/jekyll-tailwindcss"
197
+ end
119
198
  ```
120
199
 
121
200
  ### Cutting a release
@@ -126,7 +205,7 @@ gem "jekyll-tailwindcss", path: "/path/to/jekyll-tailwindcss"
126
205
  - [ ] commit and create a git tag ( example `git tag -a v0.3.1 -m "Release 0.3.1"` )
127
206
  - push
128
207
  - [ ] `bundle exec rake build`
129
- - [ ] `gem push pkg/*.gem`
208
+ - [ ] `gem push pkg/jekyll-tailwind-[NEW_VERSION].gem
130
209
  - [ ] `git push --follow-tags`
131
210
  - announce
132
211
  - [ ] create a release at https://github.com/vormwald/jekyll-tailwindcss/releases
@@ -135,8 +214,6 @@ gem "jekyll-tailwindcss", path: "/path/to/jekyll-tailwindcss"
135
214
 
136
215
  Bug reports and pull requests are welcome on GitHub at https://github.com/vormwald/jekyll-tailwindcss. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/vormwald/jekyll-tailwindcss/blob/main/CODE_OF_CONDUCT.md).
137
216
 
138
-
139
-
140
217
  ## License
141
218
 
142
219
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -16,21 +16,25 @@ module Jekyll
16
16
  end
17
17
 
18
18
  def convert(content)
19
- return content unless /@tailwind/i.match?(content)
19
+ return content unless /@tailwind|@import ['"]tailwindcss['"]/i.match?(content)
20
+ if content.include?("@tailwind") && config_path.nil?
21
+ Jekyll.logger.error "Jekyll Tailwind:", "to use tailwind v3 you need to include a config path in _config.yml"
22
+ return content
23
+ end
20
24
 
21
25
  dev_mode = Jekyll.env == "development"
22
26
  Jekyll.logger.info "Jekyll Tailwind:", "Generating #{dev_mode ? "" : "minified "}CSS"
23
27
 
24
28
  compile_command = ::Tailwindcss::Commands
25
- .compile_command(debug: dev_mode, config: config_location)
29
+ .compile_command(debug: dev_mode, config_path: config_path, postcss_path: postcss_path)
26
30
  .join(" ")
27
31
 
28
32
  output, error = nil
29
33
  Open3.popen3(tailwindcss_env_options, compile_command) do |stdin, stdout, stderr, _wait_thread|
30
34
  stdin.write content # write the content of *.tailwindcss to the tailwindcss CLI as input
31
35
  stdin.close
32
- error = stderr.read
33
36
  output = stdout.read
37
+ error = stderr.read
34
38
  end
35
39
  Jekyll.logger.warn "Jekyll Tailwind:", error unless error.nil?
36
40
 
@@ -48,8 +52,12 @@ module Jekyll
48
52
  {"BROWSERSLIST_IGNORE_OLD_DATA" => "1"}
49
53
  end
50
54
 
51
- def config_location
52
- @config.dig("tailwindcss", "config") || "./tailwind.config.js"
55
+ def config_path
56
+ @config.dig("tailwindcss", "config")
57
+ end
58
+
59
+ def postcss_path
60
+ @config.dig("tailwindcss", "postcss")
53
61
  end
54
62
  end
55
63
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Tailwindcss
5
- VERSION = "0.5.0"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
@@ -3,18 +3,16 @@ require "tailwindcss/ruby"
3
3
  module Tailwindcss
4
4
  module Commands
5
5
  class << self
6
- def compile_command(debug: false, config: nil, **kwargs)
6
+ def compile_command(debug: false, config_path: nil, postcss_path: nil, **kwargs)
7
7
  command = [
8
8
  Tailwindcss::Ruby.executable(**kwargs),
9
9
  "--input", "-"
10
10
  ]
11
- command += ["--config", config] if config
11
+ command += ["--config", config_path] if config_path
12
+ command += ["--postcss", postcss_path] if postcss_path
12
13
 
13
14
  command << "--minify" unless debug
14
15
 
15
- postcss_path = "postcss.config.js"
16
- command += ["--postcss", postcss_path] if File.exist?(postcss_path)
17
-
18
16
  command
19
17
  end
20
18
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-tailwindcss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Vormwald
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-19 00:00:00.000000000 Z
10
+ date: 2025-02-13 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: tailwindcss-ruby
@@ -24,29 +23,24 @@ dependencies:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
25
  version: '0'
27
- description:
28
26
  email:
29
27
  - mvormwald@gmail.com
30
- executables:
31
- - jekyll-tailwindcss
28
+ executables: []
32
29
  extensions: []
33
30
  extra_rdoc_files: []
34
31
  files:
35
32
  - LICENSE
36
33
  - README.md
37
34
  - Rakefile
38
- - exe/jekyll-tailwindcss
39
35
  - lib/jekyll-tailwindcss.rb
40
36
  - lib/jekyll-tailwindcss/version.rb
41
37
  - lib/jekyll/converters/tailwindcss.rb
42
38
  - lib/tailwindcss/commands.rb
43
- - lib/tailwindcss/upstream.rb
44
39
  homepage: https://github.com/vormwald/jekyll-tailwindcss
45
40
  licenses:
46
41
  - MIT
47
42
  metadata:
48
43
  homepage_uri: https://github.com/vormwald/jekyll-tailwindcss
49
- post_install_message:
50
44
  rdoc_options: []
51
45
  require_paths:
52
46
  - lib
@@ -61,8 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
55
  - !ruby/object:Gem::Version
62
56
  version: '0'
63
57
  requirements: []
64
- rubygems_version: 3.5.11
65
- signing_key:
58
+ rubygems_version: 3.6.2
66
59
  specification_version: 4
67
60
  summary: Integrate Tailwind CSS into your Jekyll site.
68
61
  test_files: []
@@ -1,18 +0,0 @@
1
- #! /usr/bin/env ruby
2
- # because rubygems shims assume a gem's executables are Ruby
3
-
4
- require "tailwindcss/commands"
5
-
6
- begin
7
- command = [Tailwindcss::Commands.executable, *ARGV]
8
- if Gem.win_platform?
9
- # use system rather than exec as exec inexplicably fails to find the executable on Windows
10
- # see related https://github.com/rubys/sprockets-esbuild/pull/4
11
- system(*command, exception: true)
12
- else
13
- exec(*command)
14
- end
15
- rescue Tailwindcss::Commands::UnsupportedPlatformException, Tailwindcss::Commands::ExecutableNotFoundException => e
16
- warn("ERROR: " + e.message)
17
- exit 1
18
- end
@@ -1,7 +0,0 @@
1
- module Tailwindcss
2
- # constants describing the upstream tailwindcss project
3
- module Upstream
4
- VERSION = Tailwindcss::Ruby::Upstream::VERSION
5
- deprecate_constant :VERSION
6
- end
7
- end