simpacker 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/simpacker.rb +3 -6
- data/lib/simpacker/configuration.rb +2 -2
- data/lib/simpacker/context.rb +10 -0
- data/lib/simpacker/helper.rb +9 -5
- data/lib/simpacker/manifest.rb +6 -6
- data/lib/simpacker/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 444b754848602fa63f5531bc7beb0d50714a686ff63bd58192373bac6c66c40f
|
4
|
+
data.tar.gz: 1fca8576ce3d3d982ab9b23ca043757e98d3bc5af35522cff0f4e2615323b4e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84a3dfc8d926d60e407e0b6c34527e4ba153165f6143f2a5d406cf02d276e69bb19c2b9112c01e89b5c200ce2676d2bc0f9349d203f805c8804cad6599fb35b2
|
7
|
+
data.tar.gz: 6fa86aa1d886cdc732a94b9c90ca3961d427472ef98a30eb67931ef0fd78d5914dd591a3f0ac9fe0ba32a8049fd678b4d7e603e693860ba23870b5995acf9f75
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ Add `javascript_pack_tag` in view.
|
|
31
31
|
Run the folloing command to build JavaScript.
|
32
32
|
|
33
33
|
```
|
34
|
-
$
|
34
|
+
$ ./node_modules/.bin/wabpack --watch
|
35
35
|
```
|
36
36
|
|
37
37
|
## Integrations
|
@@ -44,7 +44,7 @@ Simpacker does not provide feature for deployment. Just run the following comman
|
|
44
44
|
|
45
45
|
```
|
46
46
|
$ npm install
|
47
|
-
$ NODE_ENV=production
|
47
|
+
$ NODE_ENV=production ./node_modules/.bin/webpack
|
48
48
|
```
|
49
49
|
|
50
50
|
## Contributing
|
data/lib/simpacker.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
+
require "simpacker/context"
|
1
2
|
require "simpacker/configuration"
|
2
3
|
require "simpacker/manifest"
|
3
4
|
require "simpacker/helper"
|
4
5
|
require "simpacker/railtie"
|
5
6
|
|
6
7
|
module Simpacker
|
7
|
-
def self.
|
8
|
-
@
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.manifest
|
12
|
-
@manifest ||= Simpacker::Manifest.new(config)
|
8
|
+
def self.default_context
|
9
|
+
@default_context ||= Simpacker::Context.new
|
13
10
|
end
|
14
11
|
end
|
@@ -4,8 +4,8 @@ module Simpacker
|
|
4
4
|
class Configuration
|
5
5
|
attr_accessor :root_path, :config_path, :env
|
6
6
|
|
7
|
-
def initialize
|
8
|
-
@root_path =
|
7
|
+
def initialize(root_path:)
|
8
|
+
@root_path = root_path
|
9
9
|
@config_path = @root_path.join("config/simpacker.yml")
|
10
10
|
@env = Rails.env
|
11
11
|
end
|
data/lib/simpacker/helper.rb
CHANGED
@@ -2,28 +2,32 @@ module Simpacker
|
|
2
2
|
module Helper
|
3
3
|
def javascript_pack_tag(*names, **options)
|
4
4
|
sources = names.map do |name|
|
5
|
-
|
5
|
+
simpacker_context.manifest.lookup!("#{name}#{compute_asset_extname(name.to_s, type: :javascript)}")
|
6
6
|
end
|
7
7
|
javascript_include_tag(*sources, **options)
|
8
8
|
end
|
9
9
|
|
10
10
|
def stylesheet_pack_tag(*names, **options)
|
11
11
|
sources = names.map do |name|
|
12
|
-
|
12
|
+
simpacker_context.manifest.lookup!("#{name}#{compute_asset_extname(name.to_s, type: :stylesheet)}")
|
13
13
|
end
|
14
14
|
stylesheet_link_tag(*sources, **options)
|
15
15
|
end
|
16
16
|
|
17
17
|
def asset_pack_path(name, **options)
|
18
|
-
asset_path(
|
18
|
+
asset_path(simpacker_context.manifest.lookup!(name), **options)
|
19
19
|
end
|
20
20
|
|
21
21
|
def asset_pack_url(name, **options)
|
22
|
-
asset_url(
|
22
|
+
asset_url(simpacker_context.manifest.lookup!(name), **options)
|
23
23
|
end
|
24
24
|
|
25
25
|
def image_pack_tag(name, **options)
|
26
|
-
image_tag(asset_path(
|
26
|
+
image_tag(asset_path(simpacker_context.manifest.lookup!(name)), **options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def simpacker_context
|
30
|
+
Simpacker.default_context
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
data/lib/simpacker/manifest.rb
CHANGED
@@ -2,10 +2,10 @@ module Simpacker
|
|
2
2
|
class Manifest
|
3
3
|
class MissingEntryError < StandardError; end
|
4
4
|
|
5
|
-
attr_reader :
|
5
|
+
attr_reader :context
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
7
|
+
def initialize(context)
|
8
|
+
@context = context
|
9
9
|
end
|
10
10
|
|
11
11
|
def lookup(name)
|
@@ -23,7 +23,7 @@ module Simpacker
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def data
|
26
|
-
if config.cache_manifest?
|
26
|
+
if context.config.cache_manifest?
|
27
27
|
@data ||= load
|
28
28
|
else
|
29
29
|
load
|
@@ -31,8 +31,8 @@ module Simpacker
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def load
|
34
|
-
if config.manifest_path.exist?
|
35
|
-
JSON.parse(config.manifest_path.read)
|
34
|
+
if context.config.manifest_path.exist?
|
35
|
+
JSON.parse(context.config.manifest_path.read)
|
36
36
|
else
|
37
37
|
{}
|
38
38
|
end
|
data/lib/simpacker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simpacker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuhito Hokamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/install/template.rb
|
103
103
|
- lib/simpacker.rb
|
104
104
|
- lib/simpacker/configuration.rb
|
105
|
+
- lib/simpacker/context.rb
|
105
106
|
- lib/simpacker/helper.rb
|
106
107
|
- lib/simpacker/manifest.rb
|
107
108
|
- lib/simpacker/railtie.rb
|