middleman-autoprefixer 2.4.4 → 2.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c87a50b11df32a3733daf1a49ccfe35af50fecb
4
- data.tar.gz: f330591667a314ba2909d414b05fabcc80414383
3
+ metadata.gz: 85bfe06bddebec420d6353a9a1eda1c0d6aadda8
4
+ data.tar.gz: 823f9301fdfc70c4d1418c1a242f093fe9722e92
5
5
  SHA512:
6
- metadata.gz: f32161e0283b6d59125930ddca7ca0b3a4e6428caaa01a55d2cffce2f5d4b8f0226de62547f3ee534fd9febbed94f2c4c21e66579a56ab35738a65fac43c8e0d
7
- data.tar.gz: 9cf4537ae2047d3225d08f481fd1dfcf8096fbd554d1bffac5f68f0e66d2d1b43557c2a6c1b47d1c1c549a4cc35750bc8d4c39c079fd3a534eadc81775133c83
6
+ metadata.gz: a38c5e06fdbd0c68fced07514c1ee483a323edd195ae2638aeace9c4c30bd38540d4190b3f1b95485d075fa9aa9eade168f5dffa8858b394e8a615daf17ab0f5
7
+ data.tar.gz: 3c3e2311a15d225e2c6ecd355573a78dc5395ff4202485b423b2e61535edaa1cd3294e4848431afd9cef886e648d0c596d3df5527edac08e146811e895745c1a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v2.5.0
2
+
3
+ * Added support for the `remove` option.
4
+ * Performance improvements and better error handling ([#19](https://github.com/middleman/middleman-autoprefixer/issues/19)).
5
+
1
6
  # v2.4.4
2
7
 
3
8
  * Updated Autoprefixer.
data/README.md CHANGED
@@ -20,11 +20,12 @@ activate :autoprefixer
20
20
 
21
21
  ## Configuration
22
22
 
23
- The extension has 4 optionally configurable fields:
23
+ The extension has 5 optionally configurable fields:
24
24
 
25
25
  ```ruby
26
26
  activate :autoprefixer do |config|
27
27
  config.browsers = ['last 2 versions', 'Explorer >= 9']
28
+ config.remove = false
28
29
  config.cascade = false
29
30
  config.inline = true
30
31
  config.ignore = ['hacks.css']
@@ -35,6 +36,10 @@ end
35
36
 
36
37
  The list of targeted browsers. Takes values and uses defaults accordingly to [Autoprefixer’s documentation](https://github.com/postcss/autoprefixer#browsers).
37
38
 
39
+ ### remove
40
+
41
+ Whether to remove outdated prefixes: `true` or `false`. Enabled by default.
42
+
38
43
  ### cascade
39
44
 
40
45
  The visual cascade of prefixed properties: `true` or `false`. Uses the default value accordingly to [Autoprefixer’s documentation](https://github.com/postcss/autoprefixer#visual-cascade).
@@ -22,6 +22,12 @@ Feature: Postprocessing stylesheets with Autoprefixer in different configuration
22
22
  Then I should see "-webkit-transition"
23
23
  And I should not see "-moz-transition"
24
24
 
25
+ Scenario: Removing is off
26
+ Given the Server is running at "removing-off-app"
27
+ When I go to "/stylesheets/page.css"
28
+ Then I should see "-webkit-transition"
29
+ And I should see "-moz-transition"
30
+
25
31
  Scenario: Cascading is on
26
32
  Given the Server is running at "cascading-on-app"
27
33
  When I go to "/stylesheets/page.css"
@@ -0,0 +1,5 @@
1
+ activate :autoprefixer do |config|
2
+ config.browsers = 'Firefox 15'
3
+ config.cascade = true
4
+ config.remove = false
5
+ end
File without changes
@@ -0,0 +1,4 @@
1
+ a {
2
+ -webkit-transition: color 0.25s ease-out;
3
+ transition: color 0.25s ease-out;
4
+ }
@@ -1,24 +1,23 @@
1
1
  module Middleman
2
2
  module Autoprefixer
3
3
  class Extension < ::Middleman::Extension
4
- option :browsers, nil, 'Supported browsers'
5
- option :cascade, nil, 'Should it cascade'
6
- option :inline, false, 'Whether to prefix CSS inline within HTML files'
7
- option :ignore, [], 'Patterns to avoid prefixing'
4
+ option :browsers, nil, 'Supported browsers (see https://github.com/ai/browserslist)'
5
+ option :cascade, true, 'Align prefixed properties'
6
+ option :inline, false, 'Prefix inline CSS within HTML files'
7
+ option :remove, true, 'Remove outdated CSS prefixes'
8
+ option :ignore, [], 'File patterns to avoid prefixing'
8
9
 
9
10
  def initialize(app, options = {}, &block)
10
11
  super
11
12
 
12
13
  require 'middleman-core/util'
13
- require 'autoprefixer-rails'
14
+ require 'autoprefixer-rails/result'
15
+ require 'autoprefixer-rails/processor'
14
16
  end
15
17
 
16
18
  def after_configuration
17
19
  # Setup Rack middleware to apply prefixes
18
- app.use Rack, browsers: options[:browsers],
19
- cascade: options[:cascade],
20
- inline: options[:inline],
21
- ignore: options[:ignore]
20
+ app.use Rack, options
22
21
  end
23
22
 
24
23
  # Rack middleware to look for CSS and apply prefixes.
@@ -30,10 +29,14 @@ module Middleman
30
29
  # @param [Hash] options
31
30
  def initialize(app, options = {})
32
31
  @app = app
33
- @browsers = options[:browsers]
34
- @cascade = options[:cascade]
35
32
  @inline = options[:inline]
36
33
  @ignore = options[:ignore]
34
+
35
+ config = {}
36
+ config[:browsers] = Array(options[:browsers])
37
+ config[:cascade] = options[:cascade]
38
+ config[:remove] = options[:remove]
39
+ @processor = ::AutoprefixerRails::Processor.new(config)
37
40
  end
38
41
 
39
42
  # Rack interface
@@ -59,7 +62,7 @@ module Middleman
59
62
 
60
63
  def process(response, type, path)
61
64
  if standalone_css_content?(type, path)
62
- prefix(extract_styles(response))
65
+ prefix(extract_styles(response), path)
63
66
  elsif inline_html_content?(type, path)
64
67
  prefix_inline_styles(extract_styles(response))
65
68
  else
@@ -67,12 +70,8 @@ module Middleman
67
70
  end
68
71
  end
69
72
 
70
- def prefix(content)
71
- config = {}
72
- config[:browsers] = Array(@browsers) unless @browsers.nil?
73
- config[:cascade] = @cascade unless @cascade.nil?
74
-
75
- ::AutoprefixerRails.process(content, config).css
73
+ def prefix(content, path = nil)
74
+ @processor.process(content, path ? { from: path } : {}).css
76
75
  end
77
76
 
78
77
  def prefix_inline_styles(content)
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module Autoprefixer
3
- VERSION = '2.4.4'.freeze
3
+ VERSION = '2.5.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-autoprefixer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.4
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Porada
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-28 00:00:00.000000000 Z
12
+ date: 2015-06-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: middleman-core
@@ -164,6 +164,9 @@ files:
164
164
  - fixtures/proxy-app/config.rb
165
165
  - fixtures/proxy-app/source/index.html
166
166
  - fixtures/proxy-app/source/stylesheets/page.scss
167
+ - fixtures/removing-off-app/config.rb
168
+ - fixtures/removing-off-app/source/index.html
169
+ - fixtures/removing-off-app/source/stylesheets/page.css
167
170
  - lib/middleman-autoprefixer.rb
168
171
  - lib/middleman-autoprefixer/extension.rb
169
172
  - lib/middleman-autoprefixer/version.rb
@@ -220,3 +223,6 @@ test_files:
220
223
  - fixtures/proxy-app/config.rb
221
224
  - fixtures/proxy-app/source/index.html
222
225
  - fixtures/proxy-app/source/stylesheets/page.scss
226
+ - fixtures/removing-off-app/config.rb
227
+ - fixtures/removing-off-app/source/index.html
228
+ - fixtures/removing-off-app/source/stylesheets/page.css