sprockets-standalone 1.2.1 → 3.0.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 +4 -6
- data/lib/sprockets/standalone.rb +5 -71
- data/lib/sprockets/standalone/version.rb +1 -1
- data/sprockets-standalone.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d698d658b9b0eda1bf448470222e66084d68fd8c
|
4
|
+
data.tar.gz: c8ece875b6b8ff1c5db49557a20003ad33d8a63a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29f7a59e76a66484f68e34861567962f3535e8dc9f94adf87d1eabf3f3d1fa0755b959e069e86e0e4530d5e063b1b803568868f75fd2921d021c8eb6321eeaca
|
7
|
+
data.tar.gz: 4cb8d6c8a534f778ce39b585e1c239cd8e165ab476c669c09a325992c5fe6185363419247a957fb9d70434ba600d114a6bd5fae1fce16be8450802b298fea7d8
|
data/README.md
CHANGED
@@ -27,8 +27,7 @@ Sprockets::Standalone::RakeTask.new(:assets) do |task, sprockets|
|
|
27
27
|
task.assets = %w(app.js app.css *.png *.svg *.woff)
|
28
28
|
task.sources = %w(app/assets vendor/assets)
|
29
29
|
task.output = File.expand_path('../assets', __FILE__)
|
30
|
-
task.
|
31
|
-
task.digest = false
|
30
|
+
task.manifest_name = 'manifest.json'
|
32
31
|
|
33
32
|
sprockets.js_compressor = :uglifier
|
34
33
|
sprockets.css_compressor = :sass
|
@@ -45,15 +44,14 @@ If you pass a block you can configure additional parameters:
|
|
45
44
|
|
46
45
|
3) `task.output` - Define output directory. Default is `dist`.
|
47
46
|
|
48
|
-
4) `task.
|
47
|
+
4) `task.manifest_name` - Set the name to be used for the `manifest.json`
|
49
48
|
|
50
|
-
5) `task.
|
51
|
-
|
52
|
-
6) `task.environment` - Set custom sprockets environment.
|
49
|
+
5) `task.environment` - Set custom sprockets environment.
|
53
50
|
|
54
51
|
You can also customize the sprockets environment in the block to configure additional preprocessors or compressors.
|
55
52
|
|
56
53
|
Note: Sprockets-standalone will always use a manifest.json even when asset digests are turned off. The manifest.json will be used to track changes. If you manually change the generated assets that will not be override when compiling assets unless there is also a change if the matching source files.
|
54
|
+
|
57
55
|
You will need to remove generated assets (`rake assets:clobber`) to force regeneration of all assets.
|
58
56
|
|
59
57
|
## Contributing
|
data/lib/sprockets/standalone.rb
CHANGED
@@ -25,21 +25,18 @@ module Sprockets
|
|
25
25
|
# working directory.
|
26
26
|
attr_accessor :output
|
27
27
|
|
28
|
-
# If assets should include digest. Default is false.
|
29
|
-
attr_accessor :digest
|
30
|
-
|
31
|
-
# If assets should be compressed. Default is false.
|
32
|
-
attr_accessor :compress
|
33
|
-
|
34
28
|
# `Environment` instance used for finding assets.
|
35
29
|
attr_accessor :environment
|
36
30
|
|
31
|
+
# Full path to the manifest json file
|
32
|
+
attr_accessor :manifest_name
|
33
|
+
|
37
34
|
def index
|
38
35
|
@index ||= environment.index if environment
|
39
36
|
end
|
40
37
|
|
41
38
|
def manifest
|
42
|
-
@manifest ||= Sprockets::
|
39
|
+
@manifest ||= Sprockets::Manifest.new index, File.join(output, manifest_name)
|
43
40
|
end
|
44
41
|
|
45
42
|
def initialize(*args)
|
@@ -47,8 +44,7 @@ module Sprockets
|
|
47
44
|
@assets = %w(application.js application.css *.png *.jpg *.gif)
|
48
45
|
@sources = []
|
49
46
|
@output = File.expand_path('dist', Dir.pwd)
|
50
|
-
@
|
51
|
-
@compress = false
|
47
|
+
@manifest_name = 'manifest.json'
|
52
48
|
|
53
49
|
@environment = Sprockets::Environment.new(Dir.pwd) do |env|
|
54
50
|
env.logger = Logger.new $stdout
|
@@ -59,9 +55,6 @@ module Sprockets
|
|
59
55
|
|
60
56
|
Array(sources).each { |source| environment.append_path source }
|
61
57
|
|
62
|
-
manifest.compress_assets = !!@compress
|
63
|
-
manifest.digest_assets = !!@digest
|
64
|
-
|
65
58
|
namespace @namespace do
|
66
59
|
desc 'Compile assets'
|
67
60
|
task :compile do
|
@@ -80,64 +73,5 @@ module Sprockets
|
|
80
73
|
end
|
81
74
|
end
|
82
75
|
end
|
83
|
-
|
84
|
-
class Manifest < ::Sprockets::Manifest
|
85
|
-
attr_writer :digest_assets
|
86
|
-
def digest_assets?
|
87
|
-
!!@digest_assets
|
88
|
-
end
|
89
|
-
|
90
|
-
attr_writer :compress_assets
|
91
|
-
def compress_assets?
|
92
|
-
!!@compress_assets
|
93
|
-
end
|
94
|
-
|
95
|
-
def compile(*args)
|
96
|
-
unless environment
|
97
|
-
raise Error, "manifest requires environment for compilation"
|
98
|
-
end
|
99
|
-
|
100
|
-
paths = environment.each_logical_path(*args).to_a +
|
101
|
-
args.flatten.select { |fn| Pathname.new(fn).absolute? if fn.is_a?(String)}
|
102
|
-
|
103
|
-
if (missing_paths = (args.reject{|p| p.include?('*')} - paths)).any?
|
104
|
-
missing_paths.each do |path|
|
105
|
-
logger.warn "Asset #{path} not found."
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
paths.each do |path|
|
110
|
-
if asset = find_asset(path)
|
111
|
-
compile_asset asset
|
112
|
-
end
|
113
|
-
end
|
114
|
-
save
|
115
|
-
paths
|
116
|
-
end
|
117
|
-
|
118
|
-
def compile_asset(asset)
|
119
|
-
path = digest_assets? ? asset.digest_path : asset.logical_path
|
120
|
-
target = File.join(dir, path)
|
121
|
-
|
122
|
-
if files[path] && (digest = files[path]['digest'])
|
123
|
-
if digest == asset.digest && File.exists?(target)
|
124
|
-
logger.debug "Skipping #{target}, up-to-date"
|
125
|
-
return
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
files[path] = {
|
130
|
-
'logical_path' => asset.logical_path,
|
131
|
-
'mtime' => asset.mtime.iso8601,
|
132
|
-
'size' => asset.bytesize,
|
133
|
-
'digest' => asset.digest
|
134
|
-
}
|
135
|
-
assets[asset.logical_path] = path
|
136
|
-
|
137
|
-
logger.info "Writing #{target}"
|
138
|
-
asset.write_to target
|
139
|
-
asset.write_to "#{target}.gz" if asset.is_a?(BundledAsset) && compress_assets?
|
140
|
-
end
|
141
|
-
end
|
142
76
|
end
|
143
77
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sprockets-standalone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project:
|
87
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.6.13
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: Rack task library for using Sprockets standalone.
|