condenser-rails 0.0.7 → 0.0.8
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/LICENSE +1 -1
- data/README.md +116 -2
- data/lib/condenser/rails/version.rb +1 -1
- data/lib/condenser/railtie.rb +7 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baa099c52f0a3c21933bed508e7b912d8dfa2314ba57d3f8ee790a01f9608aa3
|
4
|
+
data.tar.gz: ed5e75bf4e37f04d67e379dd43c5c50c9db1004712071cdc291eb2082abe6eeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d8257facbf89af90fce66fff188cace024aeddb15949ee11d49b52c7c9c7562e6c3801b3f6772e7c0783fe1d3b4d75e95fd6ef461571a19e395fbfe44a0ae4d
|
7
|
+
data.tar.gz: 1f8646f667ebfbfc502d461b50d55fbac34a97e1f7194e4d08e08a04572c94e29957af05a497cfca4aec982f0852ebf301b6009d44299b643263ed891e73644a
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,2 +1,116 @@
|
|
1
|
-
|
2
|
-
Condenser
|
1
|
+
|
2
|
+
# Condenser Rails
|
3
|
+
|
4
|
+
Provides Condenser integration for the Rails Asset Pipeline.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
``` ruby
|
9
|
+
gem 'condenser-rails'
|
10
|
+
```
|
11
|
+
|
12
|
+
Or alternatively `require 'condenser/railtie'` in your `config/application.rb` if you have Bundler auto-require disabled.
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
|
17
|
+
### Rake task
|
18
|
+
|
19
|
+
**`rake assets:precompile`**
|
20
|
+
|
21
|
+
Deployment task that compiles any assets listed in `config.assets.precompile` to `public/assets`.
|
22
|
+
|
23
|
+
**`rake assets:clean`**
|
24
|
+
|
25
|
+
Only removes old assets (keeps the most recent 3 copies) from `public/assets`. Useful when doing rolling deploys that may still be serving old assets while the new ones are being compiled.
|
26
|
+
|
27
|
+
**`rake assets:clobber`**
|
28
|
+
|
29
|
+
Nuke `public/assets` and remove `config/manifest.json`.
|
30
|
+
|
31
|
+
#### Customize
|
32
|
+
|
33
|
+
If the basic tasks don't do all that you need, it's straight forward to redefine them and replace them with something more specific to your app.
|
34
|
+
|
35
|
+
You can also redefine the task with the built in task generator.
|
36
|
+
|
37
|
+
``` ruby
|
38
|
+
require 'condenser/rails/task'
|
39
|
+
Condenser::Rails::Task.new(Rails.application) do |t|
|
40
|
+
t.environment = lambda { Rails.application.assets }
|
41
|
+
t.assets = %w( application.js application.css )
|
42
|
+
t.keep = 5
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
Each asset task will invoke `assets:environment` first. By default this loads the Rails environment. You can override this task to add or remove dependencies for your specific compilation environment.
|
47
|
+
|
48
|
+
Also see [Condenser::Rails::Task](https://github.com/rails/condenser-rails/blob/master/lib/sprockets/rails/task.rb) and [Rake::CondenserTask](https://github.com/rails/condenser/blob/master/lib/rake/condensertask.rb).
|
49
|
+
|
50
|
+
### Initializer options
|
51
|
+
|
52
|
+
**`config.assets.precompile`**
|
53
|
+
|
54
|
+
Add additional assets to compile on deploy. Defaults to `application.js`, `application.css` and any `.jpg`, `.png`, or `.gif` files under `app/assets`.
|
55
|
+
|
56
|
+
**`config.assets.path`**
|
57
|
+
|
58
|
+
Add additional load paths to this Array. Rails includes `app/assets`, `lib/assets` and `vendor/assets` for you already. Plugins might want to add their custom paths to this.
|
59
|
+
|
60
|
+
**`config.assets.quiet`**
|
61
|
+
|
62
|
+
Suppresses logger output for asset requests. Uses the `config.assets.prefix` path to match asset requests. Defaults to `false`.
|
63
|
+
|
64
|
+
**`config.assets.prefix`**
|
65
|
+
|
66
|
+
Defaults to `/assets`. Changes the directory to compile assets to.
|
67
|
+
|
68
|
+
**`config.assets.compile`**
|
69
|
+
|
70
|
+
Enables the Condenser compile environment. If disabled, `Rails.application.assets` will be `nil` to prevent inadvertent compilation calls. View helpers will depend on assets being precompiled to `public/assets` in order to link to them. Initializers expecting `Rails.application.assets` during boot should be accessing the environment in a `config.assets.configure` block. See below.
|
71
|
+
|
72
|
+
**`config.assets.configure`**
|
73
|
+
|
74
|
+
Invokes block with environment when the environment is initialized. Allows direct access to the environment instance and lets you lazily load libraries only needed for asset compiling.
|
75
|
+
|
76
|
+
``` ruby
|
77
|
+
config.assets.configure do |env|
|
78
|
+
env.js_compressor = :uglifier
|
79
|
+
env.css_compressor = :sass
|
80
|
+
|
81
|
+
require 'my_processor'
|
82
|
+
env.register_preprocessor 'application/javascript', MyProcessor
|
83
|
+
|
84
|
+
env.logger = Rails.logger
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
**`config.assets.check_precompiled_asset`**
|
89
|
+
|
90
|
+
When enabled, an exception is raised for missing assets. This option is enabled by default.
|
91
|
+
|
92
|
+
## Complementary plugins
|
93
|
+
|
94
|
+
The following plugins provide some extras for the Sprockets Asset Pipeline.
|
95
|
+
|
96
|
+
* [sass-rails](https://github.com/rails/sass-rails)
|
97
|
+
|
98
|
+
**NOTE** That these plugins are optional. The core coffee-script, sass, less, uglify, (and many more) features are built into Sprockets itself. Many of these plugins only provide generators and extra helpers. You can probably get by without them.
|
99
|
+
|
100
|
+
|
101
|
+
## Other
|
102
|
+
|
103
|
+
### [SRI](http://www.w3.org/TR/SRI/) support
|
104
|
+
|
105
|
+
Condenser adds support for subresource integrity checks. The spec is still evolving and the API may change in backwards incompatible ways.
|
106
|
+
|
107
|
+
``` ruby
|
108
|
+
javascript_include_tag :application, integrity: true
|
109
|
+
# => "<script src="/assets/application.js" integrity="sha256-TvVUHzSfftWg1rcfL6TIJ0XKEGrgLyEq6lEpcmrG9qs="></script>"
|
110
|
+
```
|
111
|
+
|
112
|
+
Note that condenser-rails only adds integrity hashes to assets when served in a secure context (over an HTTPS connection or localhost).
|
113
|
+
|
114
|
+
## License
|
115
|
+
|
116
|
+
Condenser Rails is released under the [MIT License](MIT-LICENSE).
|
data/lib/condenser/railtie.rb
CHANGED
@@ -68,7 +68,8 @@ class Condenser::Railtie < ::Rails::Railtie
|
|
68
68
|
config.assets.precompile = %w(application.css application.js **/*.jpg **/*.png **/*.gif)
|
69
69
|
config.assets.prefix = "/assets"
|
70
70
|
config.assets.quiet = false
|
71
|
-
|
71
|
+
config.assets.manifest = 'config/manifest.json'
|
72
|
+
|
72
73
|
# initializer :quiet_assets do |app|
|
73
74
|
# if app.config.assets.quiet
|
74
75
|
# app.middleware.insert_before ::Rails::Rack::Logger, ::Condenser::Rails::QuietAssets
|
@@ -78,7 +79,7 @@ class Condenser::Railtie < ::Rails::Railtie
|
|
78
79
|
# config.assets.version = ""
|
79
80
|
config.assets.compile = true
|
80
81
|
config.assets.digest = true
|
81
|
-
config.assets.cache_limit =
|
82
|
+
config.assets.cache_limit = 100.megabytes
|
82
83
|
config.assets.compressors = [:zlib]
|
83
84
|
|
84
85
|
config.assets.configure do |app, env|
|
@@ -158,22 +159,14 @@ class Condenser::Railtie < ::Rails::Railtie
|
|
158
159
|
env.register_preprocessor 'application/javascript', Condenser::BabelProcessor
|
159
160
|
env.register_exporter 'application/javascript', Condenser::RollupProcessor
|
160
161
|
|
161
|
-
env.register_minifier 'application/javascript', resolve_minifier(config.assets.js_minifier)
|
162
|
-
env.register_minifier 'text/css', resolve_minifier(config.assets.css_minifier)
|
162
|
+
env.register_minifier 'application/javascript', resolve_minifier(config.assets.js_minifier) if config.assets.js_minifier
|
163
|
+
env.register_minifier 'text/css', resolve_minifier(config.assets.css_minifier) if config.assets.css_minifier
|
163
164
|
|
164
165
|
env.register_writer Condenser::FileWriter.new
|
165
166
|
config.assets.compressors&.each do |writer|
|
166
167
|
env.register_writer resolve_writer(writer)
|
167
168
|
end
|
168
169
|
|
169
|
-
# No more configuration changes at this point.
|
170
|
-
# With cache classes on, Sprockets won't check the FS when files
|
171
|
-
# change. Preferable in production when the FS only changes on
|
172
|
-
# deploys when the app restarts.
|
173
|
-
if config.cache_classes
|
174
|
-
env = env.cached
|
175
|
-
end
|
176
|
-
|
177
170
|
env
|
178
171
|
end
|
179
172
|
|
@@ -181,16 +174,15 @@ class Condenser::Railtie < ::Rails::Railtie
|
|
181
174
|
config = app.config
|
182
175
|
|
183
176
|
path = File.join(config.paths['public'].first, config.assets.prefix)
|
184
|
-
Condenser::Manifest.new(app.assets, path, config.assets.manifest
|
177
|
+
Condenser::Manifest.new(app.assets, path, config.assets.manifest)
|
185
178
|
end
|
186
179
|
|
187
180
|
config.after_initialize do |app|
|
188
181
|
config = app.config
|
189
182
|
|
190
183
|
if config.assets.compile
|
191
|
-
config.assets.precompile
|
192
|
-
require 'condenser/server'
|
193
184
|
app.assets = self.build_environment(app, true)
|
185
|
+
require 'condenser/server'
|
194
186
|
app.routes.prepend do
|
195
187
|
mount Condenser::Server.new(app.assets, logger: Rails.logger) => config.assets.prefix
|
196
188
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: condenser-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Bracy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: condenser
|