roger_sassc 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 101e831719d1a1943f3dd25e53025b5e1a3c9eb8
4
- data.tar.gz: 066365ca6dfb71799cbd7ddf601b42152c7a0edf
3
+ metadata.gz: 50b27e85ebc439d1b94d6f5eee0883415607ea49
4
+ data.tar.gz: 2d28944c42938e1da1edc89e525f917edc43830b
5
5
  SHA512:
6
- metadata.gz: dcbbff48f2efe1591791eae540cd289ba8d05d9b885a19f95aa9ea16888cf8ab8cff76a66ff2b3c00b2576a51d8a5013f3496568673d0da553582a6d0b664fe3
7
- data.tar.gz: 83c3271c2c72acbf44a11aad8d070094fd178ff51fd4e2100c585e70806c721f81bb12000b30e838b9f7b89ab37daf839b5eae38d4730c5953c199916ef7443d
6
+ metadata.gz: 51d66b63e74ef3a2357670391e38b8784b1698d5234bbeceda78047f6022a9adfdaf67c212517f548f49efc5af1a1a7424ff6fc7cba15b47f32b4c071d36f294
7
+ data.tar.gz: d87ca128ff668d39c2c4eb36573084cbc9289b79ce8f033fec577769b6d3de6a02049d457613c25ff5d84e6dde63031689637837dfe4760d027f7d39747a7e33
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 1.2.0
4
+ * Add ability to have external sourcemaps
5
+
3
6
  ## Version 1.1.0
4
7
  * Update sassc
5
8
 
@@ -17,11 +17,15 @@ module RogerSassc
17
17
 
18
18
  defaults = {
19
19
  load_paths: RogerSassc.load_paths,
20
- source_map: true,
21
- source_map_embed: true
20
+ source_map: true
22
21
  }
23
22
 
24
23
  @options = defaults.update(options)
24
+
25
+ # If the sourcemap is embedded, the content of the source must
26
+ # be embedded, because the paths to the sources will not be correct,
27
+ # and the browser will not be able to load the source.
28
+ @options[:source_map_contents] = true if @options[:source_map_embed]
25
29
  end
26
30
 
27
31
  def call(env)
@@ -58,7 +62,7 @@ module RogerSassc
58
62
  url = url.gsub(/.map\Z/, "")
59
63
 
60
64
  # A .css file is requested in the browser
61
- url = url[0..-4] + "scss"
65
+ url.gsub!(/\.css$/, ".scss")
62
66
 
63
67
  # Use the resolver to translate urls to file paths
64
68
  # returns nill when no file is found via url
@@ -68,10 +72,10 @@ module RogerSassc
68
72
  def create_scss_engine(scss_path)
69
73
  # Supply the filename for load path resolving
70
74
  @options[:filename] = scss_path.to_s
71
- if @options[:source_map] || @options[:source_map_embed]
72
- @options[:source_map_file] = scss_path.to_s + ".map"
73
75
 
74
- @options[:source_map] = true
76
+ # Set a sourcemap file if the sourcemap is not embedded
77
+ if @options[:source_map] && !@options[:source_map_embed]
78
+ @options[:source_map_file] = scss_path.to_s.gsub(/\.scss$/, ".css.map")
75
79
  end
76
80
 
77
81
  ::SassC::Engine.new(File.read(scss_path), @options)
@@ -48,11 +48,16 @@ module RogerSassc
48
48
 
49
49
  def compile_file(path)
50
50
  @options[:filename] = path.to_s
51
+ if @options[:source_map]
52
+ @options[:source_map_file] = path.gsub(/\.scss$/, ".css.map")
53
+ @options[:source_map_contents] = true
54
+ end
55
+
51
56
  scss = File.read(path)
57
+ engine = ::SassC::Engine.new(scss, @options)
52
58
 
53
- File.open(path.gsub(/\.scss$/, ".css"), "w+") do |file|
54
- file.write(::SassC::Engine.new(scss, @options).render)
55
- end
59
+ File.write(path.gsub(/\.scss$/, ".css"), engine.render)
60
+ File.write(path.gsub(/\.scss$/, ".css.map"), engine.source_map) if @options[:source_map]
56
61
  end
57
62
  end
58
63
  end
@@ -1,4 +1,4 @@
1
1
  # Version number
2
2
  module RogerSassc
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
@@ -1,4 +1,4 @@
1
1
  .selector .baby-selector {
2
2
  color: #000; }
3
3
 
4
- /*# sourceMappingURL=data:application/json;base64,ewoJInZlcnNpb24iOiAzLAoJImZpbGUiOiAiZ2VuZXJhbC5jc3MiLAoJInNvdXJjZXMiOiBbCgkJImdlbmVyYWwuc2NzcyIsCgkJInNyYy9fdmFyaWFibGVzLnNjc3MiCgldLAoJIm5hbWVzIjogW10sCgkibWFwcGluZ3MiOiAiQUFFQSxBQUNFLFNBRE8sQ0FDUCxjQUFjLENBQUM7RUFDYixLQUFLLEVDSkQsSUFBSSxHREtUIgp9 */
4
+ /*# sourceMappingURL=data:application/json;base64,ewoJInZlcnNpb24iOiAzLAoJImZpbGUiOiAidGVzdC9maXh0dXJlcy9nZW5lcmFsLmNzcyIsCgkic291cmNlcyI6IFsKCQkidGVzdC9maXh0dXJlcy9nZW5lcmFsLnNjc3MiLAoJCSJ0ZXN0L2ZpeHR1cmVzL3NyYy9fdmFyaWFibGVzLnNjc3MiCgldLAoJInNvdXJjZXNDb250ZW50IjogWwoJCSJAaW1wb3J0ICdzcmMvdmFyaWFibGVzJztcblxuLnNlbGVjdG9yIHtcbiAgLmJhYnktc2VsZWN0b3Ige1xuICAgIGNvbG9yOiAkYmxhY2s7XG4gIH1cbn1cbiIsCgkJIiRibGFjazogIzAwMDtcbiIKCV0sCgkibmFtZXMiOiBbXSwKCSJtYXBwaW5ncyI6ICJBQUVBLEFBQ0UsU0FETyxDQUNQLGNBQWMsQ0FBQztFQUNiLEtBQUssRUNKRCxJQUFJLEdES1QiCn0= */
@@ -10,7 +10,7 @@ module RogerSassc
10
10
  include FixtureHelper
11
11
 
12
12
  def setup
13
- setup_app(source_map: false, source_map_embed: false)
13
+ setup_app(source_map: false)
14
14
  end
15
15
 
16
16
  def teardown
@@ -60,7 +60,7 @@ module RogerSassc
60
60
  end
61
61
 
62
62
  def test_inline_source_map
63
- setup_app(source_map: true)
63
+ setup_app(source_map: true, source_map_embed: true)
64
64
 
65
65
  path = fixture_path "general.scss"
66
66
  expected_css = fixture "output_with_map.css"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roger_sassc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edwin van der Graaf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-20 00:00:00.000000000 Z
11
+ date: 2017-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sassc