sewing_kit 0.95.0 → 0.95.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/lib/sewing_kit/version.rb +1 -1
- data/lib/sewing_kit/webpack/manifest/production.rb +16 -6
- 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: 41ebcd8335cbea9ad813df8116ee2d9eb628ae279a01ad072d167980a534e932
|
4
|
+
data.tar.gz: cc99f63e71559984cf6616b5594f2dcba064916bfa452bdd623fc9152ee7b04e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f525e31bf2ac93cd30c426cc89c0db275d8126d99a370cc883b913dc70868e4bfea26b674365984bedfe9cc08d2afd97d1fec7544db9758d461e404babe6b614
|
7
|
+
data.tar.gz: 5aa0cc16500aa6a98404da3ac96402d04ea0f85b453581f83a3b996914955467587d120f4ddca4d2d89a3598f51e1bb09eb41713c152b6f5e25b8ae9d03ecf08
|
data/README.md
CHANGED
@@ -229,11 +229,17 @@ By moving everything into `package.json#dependencies`. This is necessary because
|
|
229
229
|
Ideally, by deploying to a `staging` environment. If that is not possible, a production-like local development experience is available via:
|
230
230
|
|
231
231
|
```sh
|
232
|
-
NODE_ENV=production bundle exec rake assets:precompile
|
232
|
+
NODE_ENV=production SK_SIMULATE_PRODUCTION=1 bundle exec rake assets:precompile
|
233
233
|
NODE_ENV=production SK_SIMULATE_PRODUCTION=1 dev run
|
234
234
|
```
|
235
235
|
|
236
|
-
Note
|
236
|
+
Note:
|
237
|
+
|
238
|
+
- Code changes will not be automatically recompiled in this state
|
239
|
+
- `SK_SIMULATE_PRODUCTION` does not make Rails itself run in production mode
|
240
|
+
- The most accurate way to gauge performance of the production version of an application is via a `staging` environment
|
241
|
+
|
242
|
+
After verifying production behaviour, run `bundle exec rake assets:clobber` to get back to development mode.
|
237
243
|
|
238
244
|
### My project is using `sprockets-commoner`, can I use sewing_kit too?
|
239
245
|
|
data/lib/sewing_kit/version.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'sewing_kit/webpack/manifest/base'
|
3
|
+
require 'benchmark'
|
3
4
|
require 'browserslist_useragent'
|
4
5
|
|
5
6
|
module SewingKit
|
6
7
|
module Webpack
|
7
8
|
class Manifest
|
8
9
|
class Production < Base
|
9
|
-
|
10
|
-
|
10
|
+
def initialize
|
11
|
+
@cache_by_user_agent = {}
|
12
|
+
@metadata = nil
|
13
|
+
@metadata_path = nil
|
14
|
+
end
|
11
15
|
|
12
16
|
def asset_bundle_name(user_agent)
|
13
17
|
metadata_for(user_agent)['name']
|
@@ -25,14 +29,20 @@ module SewingKit
|
|
25
29
|
private
|
26
30
|
|
27
31
|
def metadata_for(user_agent)
|
28
|
-
|
29
|
-
find_matching_metadata(metadata, user_agent)
|
30
|
-
else
|
31
|
-
metadata
|
32
|
+
time = Benchmark.realtime do
|
33
|
+
@cache_by_user_agent[user_agent] ||= find_matching_metadata(metadata, user_agent)
|
32
34
|
end
|
35
|
+
|
36
|
+
Rails.logger.debug(
|
37
|
+
"[sewing_kit] found asset metadata for #{user_agent} in #{time * 1000} milliseconds"
|
38
|
+
)
|
39
|
+
|
40
|
+
@cache_by_user_agent[user_agent]
|
33
41
|
end
|
34
42
|
|
35
43
|
def find_matching_metadata(consolidated_metadata, user_agent)
|
44
|
+
return metadata unless metadata.is_a?(Array)
|
45
|
+
|
36
46
|
found = consolidated_metadata.find do |metadata|
|
37
47
|
return nil if metadata["resolvedBrowsers"].nil?
|
38
48
|
matcher = BrowserslistUseragent::Match.new(metadata["resolvedBrowsers"], user_agent)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sewing_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.95.
|
4
|
+
version: 0.95.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Sauve
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|