sprockets_uglifier_with_source_maps 1.0.0
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 +7 -0
- data/.gitignore +20 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +69 -0
- data/Rakefile +2 -0
- data/lib/sprockets_uglifier_with_source_maps.rb +8 -0
- data/lib/sprockets_uglifier_with_source_maps/compressor.rb +32 -0
- data/lib/sprockets_uglifier_with_source_maps/railtie.rb +12 -0
- data/lib/sprockets_uglifier_with_source_maps/version.rb +3 -0
- data/uglifier_with_source_maps.gemspec +24 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 34c63d7b1b496c7e21bd25a56758015f1fb85355
|
4
|
+
data.tar.gz: 296b7ddcc6c47fe5b71d60f9a221dd578bf82db8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 523486d7ce11717c4c6411c1f1f82749d5cc70290783eafeddc45326220710787d9b06addb247f77458333f00a9c08390b552ad7fb458fbccd2ed9172cd93cd1
|
7
|
+
data.tar.gz: fc866ff60cbf78b6dbfbabf6dd9f7497f57bae94f8baf5febd88acc14462509bf1adc3a7f9347cb150bf7764c87f8cff38d33831431b6ddd072b6a19b62eeeac
|
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
/.yardoc/
|
12
|
+
/_yardoc/
|
13
|
+
/doc/
|
14
|
+
/rdoc/
|
15
|
+
/.bundle/
|
16
|
+
/lib/bundler/man/
|
17
|
+
Gemfile.lock
|
18
|
+
.ruby-version
|
19
|
+
.ruby-gemset
|
20
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alexander Pavlenko
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# SprocketsUglifierWithSourceMaps
|
2
|
+
|
3
|
+
Create source maps when compressing assets in your Rails 4.2 applications.
|
4
|
+
|
5
|
+
This gem uses Uglifier to create source maps for your concatenated javascripts in Rails.
|
6
|
+
It is meant to be used as a replacement for javascript compressor.
|
7
|
+
|
8
|
+
Source maps are useful for debugging javascript and many errors monitoring services utilize them,
|
9
|
+
for example [Rollbar](https://rollbar.com/docs/source-maps/).
|
10
|
+
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
gem 'sprockets_uglifier_with_source_maps'
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install sprockets_uglifier_with_source_maps
|
25
|
+
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
In your Rails applications environment configuration:
|
30
|
+
|
31
|
+
config.assets.js_compressor = :uglifier_with_source_maps
|
32
|
+
|
33
|
+
If you need to pass options to uglifier:
|
34
|
+
|
35
|
+
config.assets.uglifier = {output: {beautify: true, indent_level: 2}, compress: {angular: true}}
|
36
|
+
|
37
|
+
Your assets will be built as normal, also maps and concatenated sources will be provided as well in `public/assets/maps` and `public/assets/sources`.
|
38
|
+
These subdirs may be configured:
|
39
|
+
|
40
|
+
config.assets.sourcemaps_prefix = 'my_maps'
|
41
|
+
config.assets.uncompressed_prefix = 'my_sources'
|
42
|
+
|
43
|
+
|
44
|
+
## Example
|
45
|
+
|
46
|
+
$ rm -rf tmp/cache && rm -rf public/assets && DISABLE_SPRING=true RAILS_ENV=production bin/rake assets:precompile
|
47
|
+
|
48
|
+
$ tree public/assets
|
49
|
+
public/assets
|
50
|
+
├── application-f925f01bc55e9831029c1eb2c20ee889.js
|
51
|
+
├── maps
|
52
|
+
│ └── application-a3aff92c860f3876615c2d158f724865.js.map
|
53
|
+
└── sources
|
54
|
+
└── application-73a007cf2d51c423a4420b649344b52e.js
|
55
|
+
|
56
|
+
$ tail -n1 public/assets/application-f925f01bc55e9831029c1eb2c20ee889.js
|
57
|
+
//# sourceMappingURL=/assets/maps/application-a3aff92c860f3876615c2d158f724865.js.map
|
58
|
+
|
59
|
+
$ head -c115 public/assets/maps/application-a3aff92c860f3876615c2d158f724865.js.map
|
60
|
+
{"version":3,"file":"application.js","sources":["/assets/sources/application-73a007cf2d51c423a4420b649344b52e.js"],
|
61
|
+
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
1. Fork it
|
66
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
67
|
+
3. Commit your changes (`git commit -m 'Add some feature'`)
|
68
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
69
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'sprockets_uglifier_with_source_maps/version'
|
2
|
+
require 'sprockets'
|
3
|
+
require 'uglifier'
|
4
|
+
require 'sprockets_uglifier_with_source_maps/compressor'
|
5
|
+
Sprockets.register_compressor 'application/javascript', :uglifier_with_source_maps, SprocketsUglifierWithSM::Compressor
|
6
|
+
Sprockets.register_compressor 'application/javascript', :uglify_with_source_maps, SprocketsUglifierWithSM::Compressor
|
7
|
+
require 'sprockets/railtie'
|
8
|
+
require 'sprockets_uglifier_with_source_maps/railtie'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module SprocketsUglifierWithSM
|
2
|
+
class Compressor < Sprockets::UglifierCompressor
|
3
|
+
|
4
|
+
def evaluate(context, locals, &block)
|
5
|
+
options = {comments: false}.merge!(Rails.application.config.assets.uglifier.to_h)
|
6
|
+
compressed_data, sourcemap = Uglifier.new(options).compile_with_map(data)
|
7
|
+
|
8
|
+
uncompressed_filename = File.join(Rails.application.config.assets.prefix, Rails.application.config.assets.uncompressed_prefix, "#{context.logical_path}-#{digest(data)}.js")
|
9
|
+
|
10
|
+
sourcemap = JSON.parse(sourcemap)
|
11
|
+
sourcemap['file'] = "#{context.logical_path}.js"
|
12
|
+
sourcemap['sources'] = [uncompressed_filename]
|
13
|
+
sourcemap = sourcemap.to_json
|
14
|
+
|
15
|
+
sourcemap_filename = File.join(Rails.application.config.assets.prefix, Rails.application.config.assets.sourcemaps_prefix, "#{context.logical_path}-#{digest(sourcemap)}.js.map")
|
16
|
+
|
17
|
+
sourcemap_path = File.join(Rails.public_path, sourcemap_filename)
|
18
|
+
uncompressed_path = File.join(Rails.public_path, uncompressed_filename)
|
19
|
+
FileUtils.mkdir_p [File.dirname(sourcemap_path), File.dirname(uncompressed_path)]
|
20
|
+
File.open(sourcemap_path, 'w') { |f| f.write sourcemap }
|
21
|
+
File.open(uncompressed_path, 'w') { |f| f.write data }
|
22
|
+
|
23
|
+
compressed_data.concat "\n//# sourceMappingURL=#{sourcemap_filename}\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def digest(io)
|
29
|
+
Rails.application.assets.digest.update(io).hexdigest
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'action_controller/railtie'
|
2
|
+
|
3
|
+
module SprocketsUglifierWithSM
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
|
6
|
+
initializer 'sprockets-uglifier-with-source-maps.environment', after: 'sprockets.environment', group: :all do |app|
|
7
|
+
config = app.config
|
8
|
+
config.assets.sourcemaps_prefix ||= 'maps'
|
9
|
+
config.assets.uncompressed_prefix ||= 'sources'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'sprockets_uglifier_with_source_maps/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'sprockets_uglifier_with_source_maps'
|
7
|
+
spec.version = SprocketsUglifierWithSM::VERSION
|
8
|
+
spec.authors = ['Alexander Pavlenko']
|
9
|
+
spec.email = ['alerticus@gmail.com']
|
10
|
+
spec.summary = %q{Create javascript source maps for your Rails 4.2 applications}
|
11
|
+
spec.description = %q{sprockets_uglifier_with_source_maps creates source maps for your javascript assets along with their compression using uglifier.}
|
12
|
+
spec.homepage = 'https://github.com/AlexanderPavlenko/uglifier_with_source_maps'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'sprockets-rails', '>= 3.0.0.beta1'
|
21
|
+
spec.add_runtime_dependency 'uglifier', '>= 2.5'
|
22
|
+
spec.add_development_dependency 'bundler'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sprockets_uglifier_with_source_maps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Pavlenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sprockets-rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0.beta1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0.beta1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: uglifier
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: sprockets_uglifier_with_source_maps creates source maps for your javascript
|
70
|
+
assets along with their compression using uglifier.
|
71
|
+
email:
|
72
|
+
- alerticus@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/sprockets_uglifier_with_source_maps.rb
|
83
|
+
- lib/sprockets_uglifier_with_source_maps/compressor.rb
|
84
|
+
- lib/sprockets_uglifier_with_source_maps/railtie.rb
|
85
|
+
- lib/sprockets_uglifier_with_source_maps/version.rb
|
86
|
+
- uglifier_with_source_maps.gemspec
|
87
|
+
homepage: https://github.com/AlexanderPavlenko/uglifier_with_source_maps
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.2.2
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Create javascript source maps for your Rails 4.2 applications
|
111
|
+
test_files: []
|