escompress 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/escompress.gemspec +31 -0
- data/lib/escompress/compressor.rb +21 -0
- data/lib/escompress/railtie.rb +4 -0
- data/lib/escompress/version.rb +3 -0
- data/lib/escompress.rb +17 -0
- metadata +57 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c90fadf990224c158502f673ddf7305f31b6cdb5ea4dddc3bcb3f7195ce6e4e9
|
4
|
+
data.tar.gz: ed32c9ff9764ad084909999633d0079ca68acb2cc97d9d0d96f5e8f73c362061
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: baf76ad89aa2fb5d8e5ff7fa01d6a1a638a70f2742fd8de1aeaaa5402432e088d6da1f292c8e177f6bd75ce76afe34650d7f053afded66b1cfe3902d9709882c
|
7
|
+
data.tar.gz: aea80a7e9a7922812196d2af5550509e372468e32a5adad39ad4f6d8530f6eb561c5c08c7bb0db5ab55a23237bbfb2c5638114ee5b3118ce8455dcfbc0089c0a
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
escompress (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
json (2.6.2)
|
11
|
+
parallel (1.22.1)
|
12
|
+
parser (3.1.2.0)
|
13
|
+
ast (~> 2.4.1)
|
14
|
+
rainbow (3.1.1)
|
15
|
+
rake (13.0.6)
|
16
|
+
regexp_parser (2.5.0)
|
17
|
+
rexml (3.2.5)
|
18
|
+
rubocop (1.31.2)
|
19
|
+
json (~> 2.3)
|
20
|
+
parallel (~> 1.10)
|
21
|
+
parser (>= 3.1.0.0)
|
22
|
+
rainbow (>= 2.2.2, < 4.0)
|
23
|
+
regexp_parser (>= 1.8, < 3.0)
|
24
|
+
rexml (>= 3.2.5, < 4.0)
|
25
|
+
rubocop-ast (>= 1.18.0, < 2.0)
|
26
|
+
ruby-progressbar (~> 1.7)
|
27
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
28
|
+
rubocop-ast (1.19.1)
|
29
|
+
parser (>= 3.1.1.0)
|
30
|
+
rubocop-performance (1.14.3)
|
31
|
+
rubocop (>= 1.7.0, < 2.0)
|
32
|
+
rubocop-ast (>= 0.4.0)
|
33
|
+
ruby-progressbar (1.11.0)
|
34
|
+
standard (1.13.0)
|
35
|
+
rubocop (= 1.31.2)
|
36
|
+
rubocop-performance (= 1.14.3)
|
37
|
+
unicode-display_width (2.2.0)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
x86_64-darwin-20
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
escompress!
|
44
|
+
rake (~> 13.0)
|
45
|
+
standard (~> 1.3)
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
2.3.11
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Justin Wilson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Escompress
|
2
|
+
|
3
|
+
Use esbuild to compress your Rails CSS (or JS if you want).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
$ bundle add escompress
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
$ gem install escompress
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
# in application.rb
|
19
|
+
|
20
|
+
# You can specify the location of your esbuild executable.
|
21
|
+
# The default location where escompress will look is /usr/local/bin/esbuild
|
22
|
+
Escompress.esbuild_executable = Rails.root.join("node_modules/esbuild/bin/esbuild")
|
23
|
+
|
24
|
+
module MyApp
|
25
|
+
class Application < Rails::Application
|
26
|
+
# ... other code
|
27
|
+
config.assets.css_compressor = Escompress::Compressor.new(loader: :css)
|
28
|
+
# config.assets.js_compressor = Escompress::Compressor.new(loader: :js)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
```
|
32
|
+
|
33
|
+
## Development
|
34
|
+
|
35
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
36
|
+
|
37
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/escompress. 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/[USERNAME]/escompress/blob/master/CODE_OF_CONDUCT.md).
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/escompress.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/escompress/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "escompress"
|
7
|
+
spec.version = Escompress::VERSION
|
8
|
+
spec.authors = ["Justin Wilson"]
|
9
|
+
spec.email = ["justin@jwils.co"]
|
10
|
+
|
11
|
+
spec.summary = "Use esbuild to compress your Rails CSS"
|
12
|
+
spec.description = "Use esbuild to compress your Rails CSS"
|
13
|
+
spec.homepage = "https://github.com/jwilsjustin/escompress"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/jwilsjustin/escompress"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/jwilsjustin/escompress/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
3
|
+
module Escompress
|
4
|
+
class Compressor
|
5
|
+
def initialize(loader:)
|
6
|
+
@loader = loader
|
7
|
+
end
|
8
|
+
|
9
|
+
def compress(input)
|
10
|
+
cmd = "#{Escompress.esbuild_executable} --loader=#{@loader} --minify"
|
11
|
+
output, err, status = Open3.capture3(cmd, stdin_data: input)
|
12
|
+
|
13
|
+
if status.success?
|
14
|
+
output
|
15
|
+
else
|
16
|
+
puts "Escompress::Compressor error: #{err} status: #{status}"
|
17
|
+
input
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/escompress.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "escompress/compressor"
|
2
|
+
require_relative "escompress/version"
|
3
|
+
require "escompress/railtie" if defined?(Rails::Railtie)
|
4
|
+
|
5
|
+
module Escompress
|
6
|
+
class Error < StandardError; end
|
7
|
+
|
8
|
+
@@esbuild_executable = "/usr/local/bin/esbuild"
|
9
|
+
|
10
|
+
def self.esbuild_executable=(path)
|
11
|
+
@@esbuild_executable = path
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.esbuild_executable
|
15
|
+
@@esbuild_executable
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: escompress
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Wilson
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Use esbuild to compress your Rails CSS
|
14
|
+
email:
|
15
|
+
- justin@jwils.co
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- CHANGELOG.md
|
21
|
+
- Gemfile
|
22
|
+
- Gemfile.lock
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- escompress.gemspec
|
27
|
+
- lib/escompress.rb
|
28
|
+
- lib/escompress/compressor.rb
|
29
|
+
- lib/escompress/railtie.rb
|
30
|
+
- lib/escompress/version.rb
|
31
|
+
homepage: https://github.com/jwilsjustin/escompress
|
32
|
+
licenses:
|
33
|
+
- MIT
|
34
|
+
metadata:
|
35
|
+
homepage_uri: https://github.com/jwilsjustin/escompress
|
36
|
+
source_code_uri: https://github.com/jwilsjustin/escompress
|
37
|
+
changelog_uri: https://github.com/jwilsjustin/escompress/CHANGELOG.md
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.6.0
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubygems_version: 3.1.6
|
54
|
+
signing_key:
|
55
|
+
specification_version: 4
|
56
|
+
summary: Use esbuild to compress your Rails CSS
|
57
|
+
test_files: []
|