sass-rails-source-maps 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.markdown +55 -0
- data/Rakefile +1 -0
- data/lib/sass-rails-source-maps.rb +19 -0
- data/lib/sass-rails-source-maps/sass_importer.rb +9 -0
- data/lib/sass-rails-source-maps/sass_template.rb +50 -0
- data/lib/sass-rails-source-maps/version.rb +3 -0
- data/sass-rails-source-maps.gemspec +27 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f706dfb8e9a356d401dd3d627b4721b8a8c19e83
|
4
|
+
data.tar.gz: b6792c5c269756253d40cfab42bada190b95a7a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a7b84358e016bd36ec55cc45cb36c08c4fe960428c49a1d848ab887265d8c7c9fde3c7397e0e87d18906317eda7b105756a1b04e084973ef533d86b5961c52c5
|
7
|
+
data.tar.gz: 3d238763943cd487a425ef0667f0591e8447956af89839a0dfdc3351b6334ef2b457c54073e37a404410e3dd92763f9611e2d529580125e966aa8d7f95a15735
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Vojtech Hyza
|
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.markdown
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Sass Rails Source Maps
|
2
|
+
|
3
|
+
This gem allows you to see your Rails 4 `.scss` source files in Google Chrome inspector, which can be useful for debugging.
|
4
|
+
|
5
|
+
`debug_info` option available in stable [sass](http://sass-lang.com/) gem is no longer working in Google Chrome, because Chrome now supports Source Map [v3](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k) only.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this to your application's Gemfile :
|
10
|
+
|
11
|
+
````ruby
|
12
|
+
group :development do
|
13
|
+
gem 'sass-rails-source-maps'
|
14
|
+
end
|
15
|
+
````
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle update sass
|
20
|
+
|
21
|
+
to use `sass` gem with Source Maps v3 support, which is currently pre-release version.
|
22
|
+
|
23
|
+
After that, run:
|
24
|
+
|
25
|
+
$ rm -rf tmp/cache/assets
|
26
|
+
$ rm -rf public/assets
|
27
|
+
|
28
|
+
to make Rails regenerate assets. After assets regeneration, `assets/source_maps` containing `sass` source maps is created in `public` directory.
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
To see something like this ![screenshot](https://www.evernote.com/shard/s36/sh/d0c3c46e-d9e7-47d0-b23b-118ca1c77add/d2268cefa01e273ecfda4aba600c8640/res/c14f6a6d-c418-4bdd-80c2-5025dc035221/skitch.png?resizeSmall&width=832) you need to enable source maps in Google Chrome.
|
33
|
+
|
34
|
+
To enable source maps open Chrome inspector go to [chrome://flags/#enable-devtools-experiments](chrome://flags/#enable-devtools-experiments) and `Enable Developer Tools experiments`. Then restart Google Chrome.
|
35
|
+
|
36
|
+
After restart, go to inspector `experimental` settings and enable `Sass stylesheet debugging` and finally in general settings check `Enable source maps`.
|
37
|
+
|
38
|
+
![experimental settings](https://www.evernote.com/shard/s36/sh/323d6df5-e5a5-467d-89bb-2e933800292a/aba9bcbf79b533e3ab625e9dc8961f61/res/f90634d7-2267-4a53-8a84-0e4baafd56d4/skitch.png?resizeSmall&width=832)
|
39
|
+
|
40
|
+
![general settings](https://www.evernote.com/shard/s36/sh/7fc204d3-b0b2-47a7-9df9-d2d03f08fb2c/46dab5f794b32ede79b9c482b21ca9fa/res/bc1ba16c-e08f-41b4-9417-23c1384b89d9/skitch.png?resizeSmall&width=832)
|
41
|
+
|
42
|
+
Enabling source maps may vary in different Chrome versions. For more info please see [Working with CSS Preprocessors](https://developers.google.com/chrome-developer-tools/docs/css-preprocessors); part _Using Sass with CSS source maps_.
|
43
|
+
|
44
|
+
## Notes
|
45
|
+
* This gem is Rails 4 compatible only
|
46
|
+
* If you wan't to see `coffeescript` files in Google Chrome inspector you can use [coffee-rails-source-maps](https://github.com/markbates/coffee-rails-source-maps) gem.
|
47
|
+
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'sprockets'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'sass-rails-source-maps/version'
|
4
|
+
require 'sass-rails-source-maps/sass_importer'
|
5
|
+
require 'sass-rails-source-maps/sass_template'
|
6
|
+
|
7
|
+
module SassRailsSourceMaps
|
8
|
+
|
9
|
+
SOURCE_MAPS_DIRECTORY = "assets/source_maps"
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
Sprockets::ScssTemplate.class_eval do
|
14
|
+
include SassRailsSourceMaps::SassTemplate
|
15
|
+
end
|
16
|
+
|
17
|
+
Sprockets::SassTemplate.class_eval do
|
18
|
+
include SassRailsSourceMaps::SassTemplate
|
19
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module SassRailsSourceMaps
|
2
|
+
module SassTemplate
|
3
|
+
|
4
|
+
def write_output(text, destination)
|
5
|
+
FileUtils.mkdir_p(Rails.root.join("public", SassRailsSourceMaps::SOURCE_MAPS_DIRECTORY))
|
6
|
+
File.open(destination, 'wb') { |file| file.write(text) }
|
7
|
+
end
|
8
|
+
|
9
|
+
def copy_dependencies(files)
|
10
|
+
files.each do |file|
|
11
|
+
FileUtils.cp(file, Rails.root.join("public", SassRailsSourceMaps::SOURCE_MAPS_DIRECTORY, File.basename(file)))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def evaluate(context, locals, &block)
|
16
|
+
cache_store = Sprockets::SassCacheStore.new(context.environment)
|
17
|
+
|
18
|
+
options = {
|
19
|
+
sourcemap_filename: ::Sass::Util::sourcemap_name(basename),
|
20
|
+
filename: eval_file,
|
21
|
+
line: line,
|
22
|
+
syntax: syntax,
|
23
|
+
cache_store: cache_store,
|
24
|
+
cache: ::Rails.application.config.assets.debug,
|
25
|
+
line_numbers: ::Rails.application.config.sass.line_numbers,
|
26
|
+
line_comments: ::Rails.application.config.sass.line_comments,
|
27
|
+
importer: SassImporter.new(context, context.pathname),
|
28
|
+
load_paths: context.environment.paths.map { |path| SassImporter.new(context, path) },
|
29
|
+
sprockets: {
|
30
|
+
context: context,
|
31
|
+
environment: context.environment
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
result, mapping = ::Sass::Engine.new(data, options).render_with_sourcemap("/#{SOURCE_MAPS_DIRECTORY}/#{options[:sourcemap_filename]}")
|
36
|
+
|
37
|
+
write_output(data, ::Rails.root.join("public", SOURCE_MAPS_DIRECTORY, basename).to_s)
|
38
|
+
write_output(mapping.to_json(
|
39
|
+
css_path: basename.gsub(".#{syntax.to_s}", ""),
|
40
|
+
sourcemap_path: ::Rails.root.join("public", SOURCE_MAPS_DIRECTORY, options[:sourcemap_filename])) + "\n",
|
41
|
+
::Rails.root.join("public", SOURCE_MAPS_DIRECTORY, options[:sourcemap_filename]).to_s)
|
42
|
+
copy_dependencies(context._dependency_paths)
|
43
|
+
|
44
|
+
result
|
45
|
+
rescue ::Sass::SyntaxError => e
|
46
|
+
context.__LINE__ = e.sass_backtrace.first[:line]
|
47
|
+
raise e
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sass-rails-source-maps/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "sass-rails-source-maps"
|
8
|
+
gem.version = SassRailsSourceMaps::VERSION
|
9
|
+
gem.authors = ["Vojtech Hyza"]
|
10
|
+
gem.email = ["vhyza@vhyza.eu"]
|
11
|
+
gem.description = %q{Rails gem for generating sass source maps}
|
12
|
+
gem.summary = %q{Rails gem for generating sass source maps}
|
13
|
+
gem.homepage = "http://github.com/vhyza/sass-rails-source-maps"
|
14
|
+
gem.license = "MIT"
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_dependency "rails"
|
22
|
+
gem.add_dependency "sprockets", ">= 2.3.0"
|
23
|
+
gem.add_dependency "sass", ">= 3.3.0.alpha.88"
|
24
|
+
|
25
|
+
gem.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
gem.add_development_dependency "rake"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sass-rails-source-maps
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Vojtech Hyza
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sprockets
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.3.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.3.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sass
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.3.0.alpha.88
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.3.0.alpha.88
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Rails gem for generating sass source maps
|
84
|
+
email:
|
85
|
+
- vhyza@vhyza.eu
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.markdown
|
94
|
+
- Rakefile
|
95
|
+
- lib/sass-rails-source-maps.rb
|
96
|
+
- lib/sass-rails-source-maps/sass_importer.rb
|
97
|
+
- lib/sass-rails-source-maps/sass_template.rb
|
98
|
+
- lib/sass-rails-source-maps/version.rb
|
99
|
+
- sass-rails-source-maps.gemspec
|
100
|
+
homepage: http://github.com/vhyza/sass-rails-source-maps
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.0.3
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Rails gem for generating sass source maps
|
124
|
+
test_files: []
|