jekyll-postcss 0.3.1 → 0.5.0

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: 635d3d12852e6842c6d3b24493c98b986578b6209ad1628c7005e4ea7f3db7ce
4
- data.tar.gz: bbafa3ff24e1186926a16ca4c9d9ae240035d95ded1e5e9005c814fe777e780f
3
+ metadata.gz: b4610bf3b4f73b8c871bdc5ae6f91ff3f461128b5ce34716486bbcbb77987a1d
4
+ data.tar.gz: d1033851975011342f10ad19c6acfd1b9168aa736cc0071766cb17eeefcd6fe5
5
5
  SHA512:
6
- metadata.gz: fcb25b23596d06b8703b9a72697e614f7733ef7c07ece2ae4537934f4758c478bef4569da98bf99f0ccedfc1d8049d8d6782c349f69685a20f11ac1821004369
7
- data.tar.gz: 669475b69a173d0aab8ea11aba25f40fadc68167ab0c099e95d94757032eefdbcce8441b487fadb5bbd00e5164e43c94d4953bbd4fa561391cf16744a9f6d609
6
+ metadata.gz: 3c9a64927c2b52f7041624b9413745b4f0e4539c2066c85533723d543c580bc946cf7e21426a02b29af2ca048eb821e896398433d0e575b560426099b787ac5f
7
+ data.tar.gz: 31b02f8c9c9b8610daff01bb5bd58622ff7354ea9f688c8d25018678996efdb3a9737dbe4ff67bc011090a7edcca938061a2c1b811319d7a8e0a6a0731f31119
@@ -0,0 +1 @@
1
+ github: mhanberg
data/.gitignore CHANGED
@@ -11,5 +11,5 @@
11
11
  .rspec_status
12
12
 
13
13
  Gemfile.lock
14
- node_modules/
14
+ node_modules
15
15
  yarn-error.log
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 2.5.3
1
+ ruby 2.7.2
data/CHANGELOG.md CHANGED
@@ -1,13 +1,46 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0
4
+
5
+ - Option to disable the cache #32 by [Tristan Dunn](https://github.com/tristandunn)
6
+ - Show full PostCSS error and stack trace #31 by [Carl Furrow](https://github.com/cfurrow)
7
+
8
+ ## 0.4.1
9
+
10
+ - Fix a weird issue where the jekyll server never booted up because the converter class got in an infinite loop trying to make a socket connection to the postcss server.
11
+
12
+ ## 0.4.0
13
+
14
+ ### Process SCSS/Sass files
15
+
16
+ The plugin now processes scss and sass files in addition to css files. This requires using the [postcss-scss](https://github.com/postcss/postcss-scss) syntax parser in your postcss.config.js
17
+
18
+ ```javascript
19
+ module.exports = {
20
+ parser: 'postcss-scss',
21
+ plugins: [
22
+ // ...
23
+ ]
24
+ };
25
+
26
+ jekyll-postcss has a higher priority, so it will hand off the the postcss output to jekyll-sass-converter to finish off compiling.
27
+
28
+ ```
29
+
30
+ ## 0.3.2
31
+
32
+ - Output valid CSS when running outside the development environment
33
+
3
34
  ## 0.3.1
4
35
 
5
- - Only run development server in development
36
+ - Only run development server in development.
37
+ - This was discovered when attempting to deploy to Netlify. You can read more about it here [#8](https://github.com/mhanberg/jekyll-postcss/issues/8), [#15](https://github.com/mhanberg/jekyll-postcss/issues/15), and [here](https://community.netlify.com/t/deploy-is-hanging-postcss-problem/14822).
6
38
 
7
39
  ## 0.3.0
8
40
 
9
41
  - Update rake
10
42
  - Performance improvement
43
+ - [Breaking?]: Uses `postcss` instead of `postcss-cli`. I think that it will continue to work without changing your dependencies since `postcss-cli` uses `postcss` as a dependency.
11
44
 
12
45
  ## 0.2.2
13
46
 
data/README.md CHANGED
@@ -13,6 +13,7 @@ Add this line to your application's Gemfile:
13
13
  ```ruby
14
14
  gem 'jekyll-postcss'
15
15
  ```
16
+
16
17
  And then add this line to your application's `_config.yml`:
17
18
 
18
19
  ```yml
@@ -33,7 +34,7 @@ Add your PostCSS plugins to a `postcss.config.js` file in the root of your repos
33
34
 
34
35
  module.exports = {
35
36
  plugins: [
36
- require("autoprefixer") // example of plugin you might use
37
+ require("autoprefixer"), // example of plugin you might use
37
38
  ...(process.env.JEKYLL_ENV == "production" // example of only using a plugin in production
38
39
  ? [require("cssnano")({ preset: "default" })]
39
40
  : [])
@@ -41,13 +42,62 @@ module.exports = {
41
42
  };
42
43
  ```
43
44
 
44
- All files with the `.css` extension will now be processed by PostCSS.
45
+ All CSS and SCSS/Sass files will now be processed by PostCSS.
46
+
47
+ ### SCSS/Sass
48
+
49
+ If using SCSS/Sass, you must have [postcss-scss](https://github.com/postcss/postcss-scss) installed and configured in your `postcss.config.js`
50
+
51
+ ```javascript
52
+ module.exports = {
53
+ parser: 'postcss-scss',
54
+ plugins: [
55
+ // ...
56
+ ]
57
+ };
58
+ ```
59
+
60
+ ### Caching
45
61
 
46
- ### Notes
62
+ Caching is enabled by default so PostCSS will only be called when the CSS content has changed. If needed you can disable caching in your Jekyll configuration to force the CSS to be recompiled every time.
63
+
64
+ If you are using the [TailwindCSS JIT](https://tailwindcss.com/docs/just-in-time-mode), you most likely need to disable the caching feature.
65
+
66
+ ```yaml
67
+ # _config.yml
68
+
69
+ postcss:
70
+ cache: false
71
+ ```
72
+
73
+ ### Deployment
74
+
75
+ When deploying, make sure to set your `JEKYLL_ENV` to something like `production` or `staging`. This is necessary to make sure that jekyll-postcss will not use internal development conveniences when building on your host's servers.
76
+
77
+ This can be done so by setting your build command like so
78
+
79
+ ```shell
80
+ JEKYLL_ENV=production bundle exec jekyll build
81
+ ```
82
+
83
+ or using your hosts proprietary configuration. Here is an example using Netlify.
84
+
85
+ ```toml
86
+ # netlify.toml
87
+
88
+ [context.production.environment]
89
+ JEKYLL_ENV = "production"
90
+
91
+ [context.branch-deploy.environment]
92
+ JEKYLL_ENV = "staging"
93
+
94
+ [context.deploy-preview.environment]
95
+ JEKYLL_ENV = "staging"
96
+ ```
47
97
 
48
- jekyll-postcss will run a development server when `JEKYLL_ENV` is set to `development`. This is the default value if you don't set it elsewhere. When building your site for production or staging, make sure to set the `JEKYLL_ENV` appropriately, or else your deploy may fail, e.g., `JEKYLL_ENV=production bundle exec jekyll build`.
98
+ ### Front Matter Reminder
49
99
 
50
- Also note that your `.css` files still need to have a [front matter](https://jekyllrb.com/docs/step-by-step/03-front-matter/) for them to be processed by Jekyll.
100
+ Your stylesheets still need to have [front matter](https://jekyllrb.com/docs/step-by-step/03-front-matter/) for them to be processed by Jekyll.
51
101
 
52
102
  ```
53
103
  ---
data/bin/postcss CHANGED
@@ -7,11 +7,11 @@ const net = require("net");
7
7
  class PostCSS {
8
8
  static process(data, write) {
9
9
  postcss(config.plugins)
10
- .process(JSON.parse(data).raw_content, { from: "stdin" })
10
+ .process(JSON.parse(data).raw_content, { from: undefined })
11
11
  .then((result) => write(result))
12
12
  .catch((error) => {
13
13
  console.error("PostCSS Error!\n");
14
- console.error(error.toString());
14
+ console.error(error);
15
15
  });
16
16
  }
17
17
 
data/bin/release ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ bundle exec rake release
data/bin/spec ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ bundle exec rspec "$@"
@@ -7,11 +7,12 @@ module Jekyll
7
7
  module Converters
8
8
  class PostCss < Converter
9
9
  safe true
10
- priority :low
10
+ priority :normal
11
11
 
12
12
  def initialize(config = {})
13
13
  super
14
14
 
15
+ @cache_enabled = config.fetch("postcss", {}).fetch("cache", true)
15
16
  @socket = config.fetch("socket") { ::PostCss::Socket.new }
16
17
  @raw_cache = nil
17
18
  @import_raw_cache = {}
@@ -19,11 +20,11 @@ module Jekyll
19
20
  end
20
21
 
21
22
  def matches(ext)
22
- ext.casecmp(".css").zero?
23
+ [".css", ".scss", ".sass"].include?(ext.downcase)
23
24
  end
24
25
 
25
- def output_ext(_ext)
26
- ".css"
26
+ def output_ext(ext)
27
+ ext
27
28
  end
28
29
 
29
30
  def convert(content)
@@ -32,7 +33,7 @@ module Jekyll
32
33
  @raw_digest = Digest::MD5.hexdigest content
33
34
  @raw_import_digests = import_digests(content)
34
35
 
35
- if cache_miss.any?
36
+ if cache_disabled? || cache_miss?
36
37
  @raw_cache = @raw_digest.dup
37
38
  @import_raw_cache = @raw_import_digests.dup
38
39
 
@@ -58,10 +59,15 @@ module Jekyll
58
59
  end
59
60
  end
60
61
 
61
- def cache_miss
62
+ def cache_disabled?
63
+ @cache_enabled == false
64
+ end
65
+
66
+ def cache_miss?
62
67
  @raw_import_digests
63
68
  .map { |import, hash| @import_raw_cache[import] != hash }
64
69
  .unshift(@raw_cache != @raw_digest)
70
+ .any?
65
71
  end
66
72
 
67
73
  def reset
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "socket"
4
4
  require "json"
5
- require "open3"
6
5
 
7
6
  module PostCss
8
7
  class Socket
@@ -30,7 +29,7 @@ module PostCss
30
29
  else
31
30
  raise "You must call PostCss#write before calling PostCss#read" if @compiled_css.nil?
32
31
 
33
- @compiled_css
32
+ decode(@compiled_css)
34
33
  end
35
34
  end
36
35
 
@@ -50,19 +49,27 @@ module PostCss
50
49
  @env == "development"
51
50
  end
52
51
 
52
+ MAX_ATTEMPTS = 100
53
+
53
54
  def start_dev_server
54
55
  Thread.new do
55
56
  system "#{START_SCRIPT} #{POSTCSS_SCRIPT} --development"
56
57
  end
57
58
 
58
- @postcss = nil
59
- while @postcss.nil?
59
+ attempts = 0
60
+ @postcss =
60
61
  begin
61
- @postcss = TCPSocket.open("localhost", 8124)
62
- rescue StandardError
63
- nil # Suppressing exceptions
62
+ TCPSocket.open("localhost", 8124)
63
+ rescue StandardError => e
64
+ attempts = attempts + 1
65
+
66
+ if attempts < MAX_ATTEMPTS
67
+ sleep 0.1
68
+ retry
69
+ else
70
+ raise "Could not connect to the PostCSS server"
71
+ end
64
72
  end
65
- end
66
73
  end
67
74
  end
68
75
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module PostCss
5
- VERSION = "0.3.1"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jekyll-postcss",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "repository": "git@github.com:mhanberg/jekyll-postcss.git",
5
5
  "author": "Mitchell Hanberg <mitch@mitchellhanberg.com>",
6
6
  "license": "MIT",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-postcss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hanberg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-17 00:00:00.000000000 Z
11
+ date: 2021-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,6 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/FUNDING.yml"
90
91
  - ".gitignore"
91
92
  - ".rspec"
92
93
  - ".rubocop.yml"
@@ -101,7 +102,9 @@ files:
101
102
  - bin/command
102
103
  - bin/console
103
104
  - bin/postcss
105
+ - bin/release
104
106
  - bin/setup
107
+ - bin/spec
105
108
  - jekyll-postcss.gemspec
106
109
  - lib/jekyll-postcss.rb
107
110
  - lib/jekyll-postcss/socket.rb
@@ -130,8 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
133
  - !ruby/object:Gem::Version
131
134
  version: '0'
132
135
  requirements: []
133
- rubyforge_project:
134
- rubygems_version: 2.7.6
136
+ rubygems_version: 3.1.4
135
137
  signing_key:
136
138
  specification_version: 4
137
139
  summary: A PostCSS plugin for Jekyll.