jekyll-tailwindcss 0.5.1 → 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 +4 -4
- data/README.md +112 -35
- data/lib/jekyll/converters/tailwindcss.rb +12 -4
- data/lib/jekyll-tailwindcss/version.rb +1 -1
- data/lib/tailwindcss/commands.rb +3 -5
- metadata +3 -5
- data/exe/jekyll-tailwindcss +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a81e85a7737089b5d8d581d0b3a2a57537246b0d9f2d959621c88947256e4655
|
4
|
+
data.tar.gz: 1dc39f0ac56a400201336c993a933a016c48c055620d85a1110da61af0d96626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
>
|
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
|
-
|
17
|
+
Or by adding the gem manually
|
18
18
|
|
19
|
-
```
|
20
|
-
|
21
|
-
|
19
|
+
```ruby
|
20
|
+
# Gemfile
|
21
|
+
# ...
|
22
|
+
group :jekyll_plugins do
|
23
|
+
# ...
|
24
|
+
gem "jekyll-tailwindcss"
|
25
|
+
end
|
22
26
|
```
|
23
27
|
|
24
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
83
|
+
```css
|
84
|
+
/* assets/css/styles.css */
|
85
|
+
---
|
86
|
+
# This yaml frontmatter is required for jekyll to process the file
|
87
|
+
---
|
50
88
|
|
51
|
-
|
52
|
-
|
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
|
-
|
98
|
+
will be converted to
|
56
99
|
|
57
|
-
|
100
|
+
```css
|
101
|
+
/* _site/assets/css/styles.css */
|
58
102
|
|
59
|
-
|
103
|
+
/*
|
104
|
+
* Tailwind generated CSS
|
105
|
+
* ...
|
106
|
+
*/
|
107
|
+
```
|
108
|
+
|
109
|
+
### PostCSS Support
|
60
110
|
|
61
|
-
|
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
|
-
```
|
113
|
+
```yaml
|
64
114
|
tailwindcss:
|
65
|
-
config:
|
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
|
-
|
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
|
-
|
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
|
-
@
|
80
|
-
@tailwind components;
|
81
|
-
@tailwind utilities;
|
146
|
+
@import "tailwindcss";
|
82
147
|
|
83
148
|
.btn {
|
84
|
-
@apply
|
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
|
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
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
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
|
@@ -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,13 +16,17 @@ 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,
|
29
|
+
.compile_command(debug: dev_mode, config_path: config_path, postcss_path: postcss_path)
|
26
30
|
.join(" ")
|
27
31
|
|
28
32
|
output, error = nil
|
@@ -48,8 +52,12 @@ module Jekyll
|
|
48
52
|
{"BROWSERSLIST_IGNORE_OLD_DATA" => "1"}
|
49
53
|
end
|
50
54
|
|
51
|
-
def
|
52
|
-
@config.dig("tailwindcss", "config")
|
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
|
data/lib/tailwindcss/commands.rb
CHANGED
@@ -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,
|
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",
|
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,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-tailwindcss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Vormwald
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-02-13 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: tailwindcss-ruby
|
@@ -25,15 +25,13 @@ dependencies:
|
|
25
25
|
version: '0'
|
26
26
|
email:
|
27
27
|
- mvormwald@gmail.com
|
28
|
-
executables:
|
29
|
-
- jekyll-tailwindcss
|
28
|
+
executables: []
|
30
29
|
extensions: []
|
31
30
|
extra_rdoc_files: []
|
32
31
|
files:
|
33
32
|
- LICENSE
|
34
33
|
- README.md
|
35
34
|
- Rakefile
|
36
|
-
- exe/jekyll-tailwindcss
|
37
35
|
- lib/jekyll-tailwindcss.rb
|
38
36
|
- lib/jekyll-tailwindcss/version.rb
|
39
37
|
- lib/jekyll/converters/tailwindcss.rb
|
data/exe/jekyll-tailwindcss
DELETED
@@ -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
|