escompress 0.3.0 → 1.0.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: 41d04aee1692b8dcb3d122a0ebce14713b990928436f20eb4d31912a3092a058
4
- data.tar.gz: 2727e34eb6c9e09fc22eebd4ed8358441078beaae8cf9fd2dec3565571c1f179
3
+ metadata.gz: '088867c5eca00c336724a38a30a420e66bf70f18461d9d84de42dc4fb67fd317'
4
+ data.tar.gz: d153ab0e78874021cf7f69326e8b343edfcfffce84c068e7dd41cf8ab3ff621e
5
5
  SHA512:
6
- metadata.gz: d64f0562372a1e9ebe51bb00c1f1fb18c6fdb8910a585226f8571dd03c07033aae6b2b5e3a690e77be5103e9e1c5ad5203f284cf39c78881f1f3ef228bbfbb56
7
- data.tar.gz: ea9b162a7c554845c4bc884807d5358e739691f63030e5004286c8bd9d7fe3cfcea4cdd76352bb5efa4e6bbc1a6f6fc65910d9616d7a64bf2840cb71dc38bb5a
6
+ metadata.gz: 137780c4633bfee644200ccc6d568d56f82d8daa61dc8666e1ccf683e9df647c541d8b0565e0ebc8d73fa2fb54b05180fcdec39a9576b6827a8c8e3753eb1acc
7
+ data.tar.gz: 5f74c1a2e10d67a8b67b7c3673ff738b922c66e9fd67eebf2928a17e7cc26f52f4cd53cbee8b580f0d724984740767a84b93539a661bb8776a598ec4c9e91a21
data/.tool-versions ADDED
@@ -0,0 +1,2 @@
1
+ nodejs 20.9.0
2
+ ruby 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
- ## [Unreleased]
1
+ ## [1.0.0] - 2023-12-21
2
2
 
3
- ## [0.1.0] - 2022-07-22
3
+ - v1.0.0 🎉
4
+ - Now you can specify your css compression with a symbol
5
+ ```ruby
6
+ config.assets.css_compressor = :escompress
7
+ ```
8
+
9
+ ## [0.3.0] - 2022-12-22
10
+
11
+ ## [0.2.0] - 2022-12-22
12
+
13
+ ## [0.1.0] - 2022-07-29
4
14
 
5
15
  - Initial release
data/Gemfile CHANGED
@@ -6,4 +6,4 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
- gem "standard", "~> 1.3"
9
+ gem "standard"
data/Gemfile.lock CHANGED
@@ -1,41 +1,140 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- escompress (0.3.0)
4
+ escompress (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ actionpack (7.1.2)
10
+ actionview (= 7.1.2)
11
+ activesupport (= 7.1.2)
12
+ nokogiri (>= 1.8.5)
13
+ racc
14
+ rack (>= 2.2.4)
15
+ rack-session (>= 1.0.1)
16
+ rack-test (>= 0.6.3)
17
+ rails-dom-testing (~> 2.2)
18
+ rails-html-sanitizer (~> 1.6)
19
+ actionview (7.1.2)
20
+ activesupport (= 7.1.2)
21
+ builder (~> 3.1)
22
+ erubi (~> 1.11)
23
+ rails-dom-testing (~> 2.2)
24
+ rails-html-sanitizer (~> 1.6)
25
+ activesupport (7.1.2)
26
+ base64
27
+ bigdecimal
28
+ concurrent-ruby (~> 1.0, >= 1.0.2)
29
+ connection_pool (>= 2.2.5)
30
+ drb
31
+ i18n (>= 1.6, < 2)
32
+ minitest (>= 5.1)
33
+ mutex_m
34
+ tzinfo (~> 2.0)
9
35
  ast (2.4.2)
10
- json (2.6.2)
36
+ base64 (0.2.0)
37
+ bigdecimal (3.1.4)
38
+ builder (3.2.4)
39
+ concurrent-ruby (1.2.2)
40
+ connection_pool (2.4.1)
41
+ crass (1.0.6)
42
+ drb (2.2.0)
43
+ ruby2_keywords
44
+ erubi (1.12.0)
45
+ i18n (1.14.1)
46
+ concurrent-ruby (~> 1.0)
47
+ io-console (0.6.0)
48
+ irb (1.10.1)
49
+ rdoc
50
+ reline (>= 0.3.8)
51
+ json (2.7.1)
52
+ language_server-protocol (3.17.0.3)
53
+ lint_roller (1.1.0)
54
+ loofah (2.22.0)
55
+ crass (~> 1.0.2)
56
+ nokogiri (>= 1.12.0)
11
57
  minitest (5.16.3)
12
- parallel (1.22.1)
13
- parser (3.1.2.0)
58
+ mutex_m (0.2.0)
59
+ nokogiri (1.15.5-x86_64-darwin)
60
+ racc (~> 1.4)
61
+ nokogiri (1.15.5-x86_64-linux)
62
+ racc (~> 1.4)
63
+ parallel (1.23.0)
64
+ parser (3.2.2.4)
14
65
  ast (~> 2.4.1)
66
+ racc
67
+ psych (5.1.1.1)
68
+ stringio
69
+ racc (1.7.3)
70
+ rack (3.0.8)
71
+ rack-session (2.0.0)
72
+ rack (>= 3.0.0)
73
+ rack-test (2.1.0)
74
+ rack (>= 1.3)
75
+ rackup (2.1.0)
76
+ rack (>= 3)
77
+ webrick (~> 1.8)
78
+ rails-dom-testing (2.2.0)
79
+ activesupport (>= 5.0.0)
80
+ minitest
81
+ nokogiri (>= 1.6)
82
+ rails-html-sanitizer (1.6.0)
83
+ loofah (~> 2.21)
84
+ nokogiri (~> 1.14)
85
+ railties (7.1.2)
86
+ actionpack (= 7.1.2)
87
+ activesupport (= 7.1.2)
88
+ irb
89
+ rackup (>= 1.0.0)
90
+ rake (>= 12.2)
91
+ thor (~> 1.0, >= 1.2.2)
92
+ zeitwerk (~> 2.6)
15
93
  rainbow (3.1.1)
16
94
  rake (13.0.6)
17
- regexp_parser (2.5.0)
18
- rexml (3.2.5)
19
- rubocop (1.31.2)
95
+ rdoc (6.6.1)
96
+ psych (>= 4.0.0)
97
+ regexp_parser (2.8.3)
98
+ reline (0.4.1)
99
+ io-console (~> 0.5)
100
+ rexml (3.2.6)
101
+ rubocop (1.57.2)
20
102
  json (~> 2.3)
103
+ language_server-protocol (>= 3.17.0)
21
104
  parallel (~> 1.10)
22
- parser (>= 3.1.0.0)
105
+ parser (>= 3.2.2.4)
23
106
  rainbow (>= 2.2.2, < 4.0)
24
107
  regexp_parser (>= 1.8, < 3.0)
25
108
  rexml (>= 3.2.5, < 4.0)
26
- rubocop-ast (>= 1.18.0, < 2.0)
109
+ rubocop-ast (>= 1.28.1, < 2.0)
27
110
  ruby-progressbar (~> 1.7)
28
- unicode-display_width (>= 1.4.0, < 3.0)
29
- rubocop-ast (1.19.1)
30
- parser (>= 3.1.1.0)
31
- rubocop-performance (1.14.3)
111
+ unicode-display_width (>= 2.4.0, < 3.0)
112
+ rubocop-ast (1.30.0)
113
+ parser (>= 3.2.1.0)
114
+ rubocop-performance (1.19.1)
32
115
  rubocop (>= 1.7.0, < 2.0)
33
116
  rubocop-ast (>= 0.4.0)
34
- ruby-progressbar (1.11.0)
35
- standard (1.13.0)
36
- rubocop (= 1.31.2)
37
- rubocop-performance (= 1.14.3)
38
- unicode-display_width (2.2.0)
117
+ ruby-progressbar (1.13.0)
118
+ ruby2_keywords (0.0.5)
119
+ standard (1.32.1)
120
+ language_server-protocol (~> 3.17.0.2)
121
+ lint_roller (~> 1.0)
122
+ rubocop (~> 1.57.2)
123
+ standard-custom (~> 1.0.0)
124
+ standard-performance (~> 1.2)
125
+ standard-custom (1.0.2)
126
+ lint_roller (~> 1.0)
127
+ rubocop (~> 1.50)
128
+ standard-performance (1.2.1)
129
+ lint_roller (~> 1.1)
130
+ rubocop-performance (~> 1.19.1)
131
+ stringio (3.1.0)
132
+ thor (1.3.0)
133
+ tzinfo (2.0.6)
134
+ concurrent-ruby (~> 1.0)
135
+ unicode-display_width (2.5.0)
136
+ webrick (1.8.1)
137
+ zeitwerk (2.6.12)
39
138
 
40
139
  PLATFORMS
41
140
  x86_64-darwin-20
@@ -44,8 +143,9 @@ PLATFORMS
44
143
  DEPENDENCIES
45
144
  escompress!
46
145
  minitest
146
+ railties
47
147
  rake (~> 13.0)
48
- standard (~> 1.3)
148
+ standard
49
149
 
50
150
  BUNDLED WITH
51
151
  2.3.11
data/README.md CHANGED
@@ -4,7 +4,13 @@ Use esbuild to compress your Rails CSS (or JS if you want).
4
4
 
5
5
  ## Why?
6
6
 
7
- You might find yourself with a Rails app that uses sass-rails (and sassc) gems. You may be stuck with these gems for legacy reasons. Ruby sass can't handle newer CSS syntaxes.
7
+ You might find yourself with a Rails app that uses sass-rails (and sassc) gems. You may be stuck with these gems for legacy reasons. But the sassc gem can't handle newer CSS syntaxes. You may see this error:
8
+
9
+ ```
10
+ SassC::SyntaxError: Error: Function rgb is missing argument $green
11
+ ```
12
+
13
+ More info: https://github.com/tailwindlabs/tailwindcss/discussions/6738
8
14
 
9
15
  ## Installation
10
16
 
@@ -12,10 +18,6 @@ Install the gem and add to the application's Gemfile by executing:
12
18
 
13
19
  $ bundle add escompress
14
20
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
16
-
17
- $ gem install escompress
18
-
19
21
  ## Usage
20
22
 
21
23
  Make sure you have `esbuild` in your package.json file. If you are using Rails, escompress will look in your node_modules folder for the esbuild executable. If not using Rails, the gem will assume the executable is located at `/usr/local/bin/esbuild` on the underlying machine.
@@ -29,8 +31,8 @@ Make sure you have `esbuild` in your package.json file. If you are using Rails,
29
31
  module MyApp
30
32
  class Application < Rails::Application
31
33
  # ... other code
32
- config.assets.css_compressor = Escompress::Compressor.new(loader: :css)
33
- # config.assets.js_compressor = Escompress::Compressor.new(loader: :js)
34
+ config.assets.css_compressor = :escompress
35
+ # config.assets.js_compressor = :escompress
34
36
  end
35
37
  end
36
38
  ```
data/escompress.gemspec CHANGED
@@ -30,4 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.require_paths = ["lib"]
31
31
 
32
32
  spec.add_development_dependency "minitest"
33
+ spec.add_development_dependency "railties"
33
34
  end
@@ -6,6 +6,12 @@ module Escompress
6
6
  @loader = loader
7
7
  end
8
8
 
9
+ def call(input)
10
+ compress(input[:data])
11
+ end
12
+
13
+ private
14
+
9
15
  def compress(input)
10
16
  cmd = "#{Escompress.esbuild_executable} --loader=#{@loader} --minify"
11
17
  output, err, status = Open3.capture3(cmd, stdin_data: input)
@@ -1,7 +1,21 @@
1
+ require "rails/railtie"
2
+
1
3
  module Escompress
2
- class Railtie < Rails::Railtie
3
- initializer "escompress_railtie.configure_rails_initialization" do
4
+ class Railtie < ::Rails::Railtie
5
+ initializer "escompress_railtie.configure_rails_initialization", group: :all do
4
6
  Escompress.esbuild_executable = Rails.root.join("node_modules/esbuild/bin/esbuild")
7
+
8
+ # Adapted from https://github.com/ahorek/terser-ruby/blob/46a23ba/lib/terser/railtie.rb
9
+ if config.respond_to?(:assets) # Ensure asset pipeline is there
10
+ config.assets.configure do |env|
11
+ # A processor is expected to respond to call() and it accepts a hash of file contents.
12
+ # It is expected to return a hash that includes a :data key.
13
+ # https://github.com/rails/sprockets/blob/main/guides/extending_sprockets.md#compressors
14
+ # https://github.com/rails/sprockets/blob/main/guides/extending_sprockets.md#extension-interface
15
+ env.register_compressor "text/css", :escompress, Escompress::Compressor.new(loader: :css)
16
+ env.register_compressor "application/javascript", :escompress, Escompress::Compressor.new(loader: :js)
17
+ end
18
+ end
5
19
  end
6
20
  end
7
21
  end
@@ -1,3 +1,3 @@
1
1
  module Escompress
2
- VERSION = "0.3.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escompress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Wilson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-22 00:00:00.000000000 Z
11
+ date: 2023-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Use esbuild to compress your Rails CSS
28
42
  email:
29
43
  - justin@jwils.co
@@ -31,6 +45,7 @@ executables: []
31
45
  extensions: []
32
46
  extra_rdoc_files: []
33
47
  files:
48
+ - ".tool-versions"
34
49
  - CHANGELOG.md
35
50
  - Gemfile
36
51
  - Gemfile.lock