sewing_kit 0.31.0 → 0.31.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sewing_kit/railtie.rb +11 -4
- data/lib/sewing_kit/version.rb +1 -1
- data/lib/sewing_kit/webpack/manifest.rb +2 -3
- data/lib/sewing_kit/webpack/manifest/base.rb +2 -4
- data/lib/sewing_kit/webpack/manifest/development.rb +1 -1
- data/lib/sewing_kit/webpack/manifest/production.rb +3 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2ff4aed0cbabd00ba3616fe4857319ebfa86aede64ff5e1786638397cdf81ba
|
4
|
+
data.tar.gz: bad9114b6759486b91aff61f4812382cbf198a3c1725bee8716be9febc8bd971
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8568933258991662f2bc7b65d5e62ebb6e86070d97fe9d9967829332ef3de1c1952d705f0d762fcd6ff1c9ac442c5743b8d874ba4da744cad6e49f8c633c6205
|
7
|
+
data.tar.gz: ae9ae754502c4f991d79b48fe608968a724872c3d6536ec52c600719d235e900b66c50b0a806bde888b71c0f405f1d9b80cb0a98b212171796999439ab344372
|
data/lib/sewing_kit/railtie.rb
CHANGED
@@ -16,10 +16,14 @@ require 'sewing_kit/webpack/dev'
|
|
16
16
|
|
17
17
|
module SewingKit
|
18
18
|
class Railtie < ::Rails::Railtie
|
19
|
+
initializer "sewing_kit.cache_production_manifest" do
|
20
|
+
unless SewingKit::Railtie.development_server?
|
21
|
+
SewingKit::CachedProductionManifest = SewingKit::Webpack::Manifest::Base.load_metadata_from_node
|
22
|
+
end
|
23
|
+
end
|
19
24
|
# rubocop:disable Metrics/BlockLength
|
20
25
|
config.after_initialize do
|
21
|
-
|
22
|
-
if is_development && (Rails.const_defined?(:Server) || ENV['SK_FORCE_DEV_SERVER'])
|
26
|
+
if SewingKit::Railtie.development_server?
|
23
27
|
webpack_dev = SewingKit::Webpack::Dev.new
|
24
28
|
webpack_dev.start
|
25
29
|
end
|
@@ -28,10 +32,13 @@ module SewingKit
|
|
28
32
|
include SewingKit::Webpack::Helper
|
29
33
|
end
|
30
34
|
end
|
31
|
-
# rubocop:enable Metrics/BlockLength
|
32
|
-
|
33
35
|
rake_tasks do
|
34
36
|
load "tasks/sewing_kit.rake"
|
35
37
|
end
|
38
|
+
|
39
|
+
def self.development_server?
|
40
|
+
Rails.env.development? && ENV['SK_SIMULATE_PRODUCTION'] != '1' &&
|
41
|
+
(Rails.const_defined?(:Server) || ENV['SK_FORCE_DEV_SERVER'])
|
42
|
+
end
|
36
43
|
end
|
37
44
|
end
|
data/lib/sewing_kit/version.rb
CHANGED
@@ -64,10 +64,9 @@ module SewingKit
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def instance
|
67
|
-
return @instance if @instance
|
68
|
-
|
69
67
|
mode = ENV['NODE_ENV'] || Rails.env.to_s
|
70
|
-
|
68
|
+
|
69
|
+
@instance ||= if mode == 'development' && ENV['SK_SIMULATE_PRODUCTION'] != '1'
|
71
70
|
Development.new
|
72
71
|
else
|
73
72
|
Production.new
|
@@ -27,7 +27,7 @@ module SewingKit
|
|
27
27
|
metadata['assets']
|
28
28
|
end
|
29
29
|
|
30
|
-
def load_metadata_from_node
|
30
|
+
def self.load_metadata_from_node
|
31
31
|
begin
|
32
32
|
stdout, stderr, status = Open3.capture3('node_modules/.bin/sewing-kit', 'manifest', "--mode=#{mode}")
|
33
33
|
rescue => e
|
@@ -43,9 +43,7 @@ module SewingKit
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
def mode
|
46
|
+
def self.mode
|
49
47
|
ENV['NODE_ENV'] || Rails.env.to_s || 'production'
|
50
48
|
end
|
51
49
|
end
|
@@ -27,7 +27,7 @@ module SewingKit
|
|
27
27
|
@metadata_path = nil
|
28
28
|
end
|
29
29
|
|
30
|
-
result = load_metadata_from_node
|
30
|
+
result = SewingKit::Webpack::Manifest::Base.load_metadata_from_node
|
31
31
|
raise LegacyManifestError, result unless result['entrypoints'] || result['development']
|
32
32
|
|
33
33
|
@metadata_path = result && result['path']
|
@@ -14,14 +14,9 @@ module SewingKit
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def metadata
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
def load_metadata
|
22
|
-
result = load_metadata_from_node
|
23
|
-
raise LegacyManifestError, result unless result['entrypoints']
|
24
|
-
result
|
17
|
+
manifest = SewingKit::CachedProductionManifest
|
18
|
+
raise LegacyManifestError, manifest unless manifest['entrypoints']
|
19
|
+
manifest
|
25
20
|
end
|
26
21
|
end
|
27
22
|
end
|