escompress 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tool-versions +2 -0
- data/CHANGELOG.md +12 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +122 -19
- data/README.md +9 -7
- data/Rakefile +5 -0
- data/escompress.gemspec +3 -0
- data/lib/escompress/compressor.rb +6 -0
- data/lib/escompress/railtie.rb +16 -2
- data/lib/escompress/version.rb +1 -1
- data/lib/escompress.rb +4 -3
- metadata +32 -3
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,48 +1,151 @@
|
|
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
|
-
|
11
|
-
|
12
|
-
|
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)
|
57
|
+
minitest (5.16.3)
|
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)
|
13
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)
|
14
93
|
rainbow (3.1.1)
|
15
94
|
rake (13.0.6)
|
16
|
-
|
17
|
-
|
18
|
-
|
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)
|
19
102
|
json (~> 2.3)
|
103
|
+
language_server-protocol (>= 3.17.0)
|
20
104
|
parallel (~> 1.10)
|
21
|
-
parser (>= 3.
|
105
|
+
parser (>= 3.2.2.4)
|
22
106
|
rainbow (>= 2.2.2, < 4.0)
|
23
107
|
regexp_parser (>= 1.8, < 3.0)
|
24
108
|
rexml (>= 3.2.5, < 4.0)
|
25
|
-
rubocop-ast (>= 1.
|
109
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
26
110
|
ruby-progressbar (~> 1.7)
|
27
|
-
unicode-display_width (>=
|
28
|
-
rubocop-ast (1.
|
29
|
-
parser (>= 3.
|
30
|
-
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)
|
31
115
|
rubocop (>= 1.7.0, < 2.0)
|
32
116
|
rubocop-ast (>= 0.4.0)
|
33
|
-
ruby-progressbar (1.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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)
|
38
138
|
|
39
139
|
PLATFORMS
|
40
140
|
x86_64-darwin-20
|
141
|
+
x86_64-linux
|
41
142
|
|
42
143
|
DEPENDENCIES
|
43
144
|
escompress!
|
145
|
+
minitest
|
146
|
+
railties
|
44
147
|
rake (~> 13.0)
|
45
|
-
standard
|
148
|
+
standard
|
46
149
|
|
47
150
|
BUNDLED WITH
|
48
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/Rakefile
CHANGED
data/escompress.gemspec
CHANGED
@@ -28,4 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.bindir = "exe"
|
29
29
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "minitest"
|
33
|
+
spec.add_development_dependency "railties"
|
31
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)
|
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
data/lib/escompress.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
require_relative "escompress/compressor"
|
2
2
|
require_relative "escompress/version"
|
3
3
|
require "escompress/railtie" if defined?(Rails::Railtie)
|
4
|
+
require "pathname"
|
4
5
|
|
5
6
|
module Escompress
|
6
7
|
class Error < StandardError; end
|
7
8
|
|
8
|
-
|
9
|
+
DEFAULT_LOCATION = "/usr/local/bin/esbuild"
|
9
10
|
|
10
11
|
def self.esbuild_executable=(path)
|
11
|
-
|
12
|
+
@esbuild_executable = Pathname.new(path)
|
12
13
|
end
|
13
14
|
|
14
15
|
def self.esbuild_executable
|
15
|
-
|
16
|
+
@esbuild_executable ||= Pathname.new(DEFAULT_LOCATION)
|
16
17
|
end
|
17
18
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
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:
|
12
|
-
dependencies:
|
11
|
+
date: 2023-12-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
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'
|
13
41
|
description: Use esbuild to compress your Rails CSS
|
14
42
|
email:
|
15
43
|
- justin@jwils.co
|
@@ -17,6 +45,7 @@ executables: []
|
|
17
45
|
extensions: []
|
18
46
|
extra_rdoc_files: []
|
19
47
|
files:
|
48
|
+
- ".tool-versions"
|
20
49
|
- CHANGELOG.md
|
21
50
|
- Gemfile
|
22
51
|
- Gemfile.lock
|