escompress 0.3.0 → 1.0.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/.tool-versions +2 -0
- data/CHANGELOG.md +12 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +119 -19
- data/README.md +9 -7
- data/escompress.gemspec +1 -0
- data/lib/escompress/compressor.rb +6 -0
- data/lib/escompress/railtie.rb +16 -2
- data/lib/escompress/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '088867c5eca00c336724a38a30a420e66bf70f18461d9d84de42dc4fb67fd317'
|
|
4
|
+
data.tar.gz: d153ab0e78874021cf7f69326e8b343edfcfffce84c068e7dd41cf8ab3ff621e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 137780c4633bfee644200ccc6d568d56f82d8daa61dc8666e1ccf683e9df647c541d8b0565e0ebc8d73fa2fb54b05180fcdec39a9576b6827a8c8e3753eb1acc
|
|
7
|
+
data.tar.gz: 5f74c1a2e10d67a8b67b7c3673ff738b922c66e9fd67eebf2928a17e7cc26f52f4cd53cbee8b580f0d724984740767a84b93539a661bb8776a598ec4c9e91a21
|
data/.tool-versions
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
## [
|
|
1
|
+
## [1.0.0] - 2023-12-21
|
|
2
2
|
|
|
3
|
-
|
|
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
data/Gemfile.lock
CHANGED
|
@@ -1,41 +1,140 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
escompress (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
|
-
|
|
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
|
-
|
|
13
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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.
|
|
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.
|
|
109
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
|
27
110
|
ruby-progressbar (~> 1.7)
|
|
28
|
-
unicode-display_width (>=
|
|
29
|
-
rubocop-ast (1.
|
|
30
|
-
parser (>= 3.
|
|
31
|
-
rubocop-performance (1.
|
|
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.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
|
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.
|
|
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 =
|
|
33
|
-
# config.assets.js_compressor =
|
|
34
|
+
config.assets.css_compressor = :escompress
|
|
35
|
+
# config.assets.js_compressor = :escompress
|
|
34
36
|
end
|
|
35
37
|
end
|
|
36
38
|
```
|
data/escompress.gemspec
CHANGED
|
@@ -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)
|
data/lib/escompress/railtie.rb
CHANGED
|
@@ -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
|
data/lib/escompress/version.rb
CHANGED
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.
|
|
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:
|
|
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
|