autoprefixer-rails 9.5.1.1 → 10.4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +165 -0
- data/README.md +17 -33
- data/lib/autoprefixer-rails/processor.rb +45 -74
- data/lib/autoprefixer-rails/railtie.rb +15 -10
- data/lib/autoprefixer-rails/result.rb +2 -0
- data/lib/autoprefixer-rails/sprockets.rb +7 -5
- data/lib/autoprefixer-rails/version.rb +4 -2
- data/lib/autoprefixer-rails.rb +3 -0
- data/lib/rake/autoprefixer_tasks.rb +2 -0
- data/vendor/autoprefixer.js +72773 -61310
- metadata +39 -42
- data/.gitignore +0 -7
- data/.rspec +0 -1
- data/.standard.yml +0 -1
- data/.travis.yml +0 -25
- data/Gemfile +0 -10
- data/Rakefile +0 -53
- data/autoprefixer-rails.gemspec +0 -32
- data/spec/app/.browserslistrc +0 -4
- data/spec/app/.gitignore +0 -2
- data/spec/app/Rakefile +0 -2
- data/spec/app/app/assets/config/manifest.js +0 -0
- data/spec/app/app/assets/stylesheets/evaluate.css.erb +0 -1
- data/spec/app/app/assets/stylesheets/loaded.sass +0 -2
- data/spec/app/app/assets/stylesheets/sass.sass +0 -1
- data/spec/app/app/assets/stylesheets/test.css +0 -3
- data/spec/app/app/assets/stylesheets/wrong.css +0 -2
- data/spec/app/app/controllers/application_controller.rb +0 -2
- data/spec/app/app/controllers/css_controller.rb +0 -6
- data/spec/app/config/application.rb +0 -16
- data/spec/app/config/autoprefixer.yml +0 -2
- data/spec/app/config/boot.rb +0 -2
- data/spec/app/config/environment.rb +0 -3
- data/spec/app/config/environments/test.rb +0 -9
- data/spec/app/config/initializers/secret_token.rb +0 -1
- data/spec/app/config/routes.rb +0 -3
- data/spec/app/config.ru +0 -2
- data/spec/autoprefixer_spec.rb +0 -112
- data/spec/processor_spec.rb +0 -25
- data/spec/rails_spec.rb +0 -40
- data/spec/railtie_spec.rb +0 -29
- data/spec/spec_helper.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daede92299c67ff8e569b081e8f75e2e7fc50934936115605a38e419a064a39e
|
4
|
+
data.tar.gz: 2d7a5fb04f55ed57881af6aa7ce444d47b9477a25345392c37aaa5c1b425a13f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 142859085b4dc649f41122a083d18272dceb2b64e44652499f6a4152d959fce0c90980e67706c053ba11a3592a54809f851ac283ee33af239a3579ef2cfb31f7
|
7
|
+
data.tar.gz: 63e283ec2cfa1ddf8ce75a840c786404f6c29a85eb8d78dfa3d164799a2527717487debdf2245abb1f6129ee3b87e28af8ec423cfd44df4a1f30936e110d6df1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,170 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 10.4.7.0
|
4
|
+
* Fixed `print-color-adjust` support in Firefox.
|
5
|
+
* Fixed `print-color-adjust` support.
|
6
|
+
* Fixed `NaN` in grid (by @SukkaW).
|
7
|
+
|
8
|
+
## 10.4.2.0
|
9
|
+
* Fixed missed `-webkit-` prefix for `width: stretch`.
|
10
|
+
* Fixed `::file-selector-button` data (by Luke Warlow).
|
11
|
+
* Ensure sprockets-rails is loaded before autoprefixer-rails (by Thomas Morgan)
|
12
|
+
|
13
|
+
## 10.4.0.0
|
14
|
+
* Added `:autofill` support (by Luke Warlow).
|
15
|
+
|
16
|
+
## 10.3.3.0
|
17
|
+
* Fixed `::file-selector-button` support (by Usman Yunusov).
|
18
|
+
* Fixed wrong `-moz-` prefix from `::file-selector-button` (by Usman Yunusov).
|
19
|
+
|
20
|
+
## 10.3.1.0
|
21
|
+
* Added `::file-selector-button` support (by Luke Warlow).
|
22
|
+
* Fixed adding wrong prefixes to `content` (by Luke Warlow).
|
23
|
+
* Fix `ReferenceError: Can't find variable: URL` (#213)
|
24
|
+
|
25
|
+
## 10.2.5.1
|
26
|
+
* Remove nodejs version check via ExecJS, to be compatible with 2.8.1 (#203)
|
27
|
+
|
28
|
+
## 10.2.5.0
|
29
|
+
* Fixed `:` support in `@supports` (by Dmitry Semigradsky).
|
30
|
+
* Update Can I Use data.
|
31
|
+
* Lock to execjs < 2.8.0 for now (#203)
|
32
|
+
|
33
|
+
## 10.2.4.0
|
34
|
+
* Fixed `transition-property` warnings (by @Sheraff).
|
35
|
+
|
36
|
+
## 10.2.0.0 "Sub rosa"
|
37
|
+
* Added TypeScript definitions (by Dmitry Semigradsky).
|
38
|
+
* Fixed docs (by Florian Pellet).
|
39
|
+
* Update Can I Use data.
|
40
|
+
* Update postcss to 8.2.2
|
41
|
+
|
42
|
+
## 10.1.0.0 "Pula"
|
43
|
+
* Fixed `Cannot read property 'proxyOf' of undefined` error (by Igor Kamyshev).
|
44
|
+
* Added `dpcm` unit support to `min-resolution: 2dppx` (by Robert Eisele).
|
45
|
+
* Fixed rational approximation in `min-resolution` (by Robert Eisele).
|
46
|
+
|
47
|
+
## 10.0.3.0
|
48
|
+
* Fixed `substract` to `subtract` value for `mask-composite` (by Michelle Enos).
|
49
|
+
* Update Can I Use data
|
50
|
+
|
51
|
+
## 10.0.2.0
|
52
|
+
* Removed -ms-user-select: all because IE and old Edge don’t support it.
|
53
|
+
* Fixed Grid Layout warning.
|
54
|
+
* Update Can I Use data
|
55
|
+
|
56
|
+
## 10.0.1.3
|
57
|
+
* Fix `fileURL.replace is not a function` when reporting warnings (#194)
|
58
|
+
|
59
|
+
## 10.0.1.2
|
60
|
+
* Workaround `existsSync not a function` (#193)
|
61
|
+
|
62
|
+
## 10.0.1.1
|
63
|
+
* Update Can I Use data.
|
64
|
+
* Update postcss to 8.1.4
|
65
|
+
* Fix issue with source map (#190)
|
66
|
+
|
67
|
+
## 10.0.1.0
|
68
|
+
* Update Can I Use data.
|
69
|
+
* Update autoprefixer to 10.0.1
|
70
|
+
* Update postcss to 8.1.1
|
71
|
+
|
72
|
+
## 10.0.0.2
|
73
|
+
* Update postcss to 8.0.5
|
74
|
+
* Update browserslist & caniuse-lite
|
75
|
+
|
76
|
+
## 10.0.0.1
|
77
|
+
* Improved error message for old environments.
|
78
|
+
* Reduced gem file size.
|
79
|
+
|
80
|
+
## 10.0 “Alis volat propriis”
|
81
|
+
* Removed support for Node.js 6.x, 8.x, 11.x.
|
82
|
+
* Moved to PostCSS 8.
|
83
|
+
|
84
|
+
## 9.8.6.5
|
85
|
+
* Fix `9.8.6.4` regression.
|
86
|
+
|
87
|
+
## 9.8.6.4
|
88
|
+
* Remove deprecation warnings.
|
89
|
+
|
90
|
+
## 9.8.6.3
|
91
|
+
* Fix deprecation warning for non-Rails environment.
|
92
|
+
|
93
|
+
## 9.8.6.2
|
94
|
+
* Print deprecation warning only once.
|
95
|
+
|
96
|
+
## 9.8.6.1
|
97
|
+
* Improve deprecated warnings.
|
98
|
+
|
99
|
+
## 9.8.6
|
100
|
+
* Fixed `env` option.
|
101
|
+
* Added deprecation warning.
|
102
|
+
|
103
|
+
## 9.8.5
|
104
|
+
* Improved Grid Layout warnings (by Daniel Tonon).
|
105
|
+
|
106
|
+
## 9.8.4
|
107
|
+
* Reduce JS bundle size.
|
108
|
+
|
109
|
+
## 9.8.3
|
110
|
+
* Update Can I Use data.
|
111
|
+
|
112
|
+
## 9.8.2
|
113
|
+
* Update Can I Use data.
|
114
|
+
|
115
|
+
## 9.8.1
|
116
|
+
* Replace `chalk` to `kleur` (by Luke Edwards).
|
117
|
+
|
118
|
+
## 9.8 “Vigilo Confido”
|
119
|
+
* Add `:placeholder-shown` support (by Tanguy Krotoff).
|
120
|
+
|
121
|
+
## 9.7.6
|
122
|
+
* Revert `-webkit-stretch` fix.
|
123
|
+
|
124
|
+
## 9.7.5
|
125
|
+
* Fix `-webkit-stretch` support.
|
126
|
+
* Reduce gem file size.
|
127
|
+
|
128
|
+
## 9.7.4
|
129
|
+
* Update Can I Use data.
|
130
|
+
|
131
|
+
## 9.7.3
|
132
|
+
* Update Can I Use data.
|
133
|
+
|
134
|
+
## 9.7.2
|
135
|
+
* Add `-ms-user-select: element` support.
|
136
|
+
|
137
|
+
## 9.7.1
|
138
|
+
* Avoid unnecessary transitions in prefixed selectors (by Andrey Alexandrov).
|
139
|
+
* Fix `fit-content` for Firefox.
|
140
|
+
|
141
|
+
## 9.7 “Ad Victoriam”
|
142
|
+
* Add `AUTOPREFIXER_GRID` env variable to enable Grid Layout polyfill for IE.
|
143
|
+
* Fix `Cannot read property 'grid' of undefined` error.
|
144
|
+
|
145
|
+
## 9.6.5
|
146
|
+
* Fix selector prefixing (by Andrey Alexandrov).
|
147
|
+
|
148
|
+
## 9.6.4
|
149
|
+
* Now the real fix for `'startsWith' of undefined` error.
|
150
|
+
|
151
|
+
## 9.6.3
|
152
|
+
* Fix `Cannot read property 'startsWith' of undefined` error.
|
153
|
+
|
154
|
+
## 9.6.2
|
155
|
+
* Fix false `Replace fill to stretch` warning.
|
156
|
+
|
157
|
+
## 9.6.1.1
|
158
|
+
* Update Can I Use data.
|
159
|
+
|
160
|
+
## 9.6.1
|
161
|
+
* Fix `-webkit-line-clamp` truncating multi-line text support.
|
162
|
+
|
163
|
+
## 9.6 “Nunc id vides, nunc ne vides”
|
164
|
+
* Add warning-less `overrideBrowserslist` option.
|
165
|
+
* Add `text-orientation` support.
|
166
|
+
* Add `min-resolution: 2x` alias support.
|
167
|
+
|
3
168
|
## 9.5.1.1
|
4
169
|
* Fix `register_postprocessor' for nil:NilClass` error.
|
5
170
|
* Update Can I Use data.
|
data/README.md
CHANGED
@@ -5,17 +5,18 @@
|
|
5
5
|
title="Autoprefixer logo by Anton Lovchikov">
|
6
6
|
|
7
7
|
[Autoprefixer] is a tool to parse CSS and add vendor prefixes to CSS rules
|
8
|
-
using values from the [Can I Use] database. This gem provides Ruby
|
9
|
-
integration with this JavaScript tool.
|
8
|
+
using values from the [Can I Use] database. This gem provides Ruby
|
9
|
+
and Ruby on Rails integration with this JavaScript tool.
|
10
10
|
|
11
11
|
<a href="https://evilmartians.com/?utm_source=autoprefixer-rails">
|
12
12
|
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
|
13
13
|
</a>
|
14
14
|
|
15
|
-
[Autoprefixer]:
|
16
|
-
[Can I Use]:
|
17
|
-
[
|
18
|
-
[ci]:
|
15
|
+
[Autoprefixer]: https://github.com/postcss/autoprefixer
|
16
|
+
[Can I Use]: http://caniuse.com/
|
17
|
+
[PostCSS]: https://postcss.org/
|
18
|
+
[ci-img]: https://travis-ci.org/ai/autoprefixer-rails.svg
|
19
|
+
[ci]: https://travis-ci.org/ai/autoprefixer-rails
|
19
20
|
|
20
21
|
## Differences
|
21
22
|
|
@@ -32,8 +33,8 @@ Windows users should install [Node.js]. Autoprefixer Rails doesn’t work with
|
|
32
33
|
old JScript in Windows.
|
33
34
|
|
34
35
|
Autoprefixer Rails uses [ExecJS] that will use the best available JavaScript
|
35
|
-
runtime. Currently this gem is tested to work with Node.js version
|
36
|
-
with [mini_racer], but will not work with [therubyracer].
|
36
|
+
runtime. Currently this gem is tested to work with Node.js version 10 and up
|
37
|
+
and with [mini_racer], but will not work with [therubyracer].
|
37
38
|
|
38
39
|
[Node.js]: http://nodejs.org/
|
39
40
|
[ExecJS]: https://github.com/rails/execjs
|
@@ -87,26 +88,15 @@ support to add vendor prefixes automatically using the Asset Pipeline:
|
|
87
88
|
}
|
88
89
|
```
|
89
90
|
|
90
|
-
If you need to specify browsers for your Rails project, you can save them
|
91
|
+
If you need to specify browsers for your Rails project, you can save them
|
92
|
+
to `.browserslistrc` and place it under `app/assets/stylesheets/`
|
93
|
+
or any of its ancestor directories
|
91
94
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
last 2 versions
|
98
|
-
IE > 8 # comment
|
99
|
-
```
|
100
|
-
|
101
|
-
* Or `config/autoprefixer.yml`
|
102
|
-
|
103
|
-
```yaml
|
104
|
-
flexbox: no-2009
|
105
|
-
browsers:
|
106
|
-
- "> 1%"
|
107
|
-
- "last 2 versions"
|
108
|
-
- "IE > 8"
|
109
|
-
```
|
95
|
+
```
|
96
|
+
> 1%
|
97
|
+
last 2 versions
|
98
|
+
IE > 8 # comment
|
99
|
+
```
|
110
100
|
|
111
101
|
See [Browserslist docs] for config format. But `> 5% in US` query is not
|
112
102
|
supported in Rails, because of ExecJS limitations. You should migrate to webpack
|
@@ -154,12 +144,6 @@ require "autoprefixer-rails"
|
|
154
144
|
prefixed = AutoprefixerRails.process(css, from: 'main.css').css
|
155
145
|
```
|
156
146
|
|
157
|
-
You can specify browsers with the `browsers` option:
|
158
|
-
|
159
|
-
```ruby
|
160
|
-
AutoprefixerRails.process(css, from: 'a.css', browsers: ['> 1%', 'ie 10']).css
|
161
|
-
```
|
162
|
-
|
163
147
|
### Compass
|
164
148
|
|
165
149
|
You should consider using Gulp instead of Compass binary,
|
@@ -1,12 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "pathname"
|
2
4
|
require "execjs"
|
3
5
|
require "json"
|
4
6
|
|
5
|
-
IS_SECTION = /^\s*\[(.+)\]\s
|
7
|
+
IS_SECTION = /^\s*\[(.+)\]\s*$/.freeze
|
6
8
|
|
7
9
|
module AutoprefixerRails
|
8
10
|
# Ruby to JS wrapper for Autoprefixer processor instance
|
9
11
|
class Processor
|
12
|
+
SUPPORTED_RUNTIMES = [ExecJS::Runtimes::Node, ExecJS::Runtimes::MiniRacer]
|
13
|
+
|
10
14
|
def initialize(params = {})
|
11
15
|
@params = params || {}
|
12
16
|
end
|
@@ -20,23 +24,18 @@ module AutoprefixerRails
|
|
20
24
|
def process(css, opts = {})
|
21
25
|
opts = convert_options(opts)
|
22
26
|
|
23
|
-
apply_wrapper =
|
24
|
-
"(function(opts, pluginOpts) {" \
|
25
|
-
"return eval(process.apply(this, opts, pluginOpts));" \
|
26
|
-
"})"
|
27
|
-
|
28
27
|
plugin_opts = params_with_browsers(opts[:from]).merge(opts)
|
29
28
|
process_opts = {
|
30
29
|
from: plugin_opts.delete(:from),
|
31
30
|
to: plugin_opts.delete(:to),
|
32
|
-
map: plugin_opts.delete(:map)
|
31
|
+
map: plugin_opts.delete(:map)
|
33
32
|
}
|
34
33
|
|
35
34
|
begin
|
36
|
-
result = runtime.call(
|
35
|
+
result = runtime.call("autoprefixer.process", css, process_opts, plugin_opts)
|
37
36
|
rescue ExecJS::ProgramError => e
|
38
37
|
contry_error = "BrowserslistError: " \
|
39
|
-
"Country statistics
|
38
|
+
"Country statistics are not supported " \
|
40
39
|
"in client-side build of Browserslist"
|
41
40
|
if e.message == contry_error
|
42
41
|
raise "Country statistics is not supported in AutoprefixerRails. " \
|
@@ -51,18 +50,18 @@ module AutoprefixerRails
|
|
51
50
|
|
52
51
|
# Return, which browsers and prefixes will be used
|
53
52
|
def info
|
54
|
-
runtime.
|
53
|
+
runtime.call("autoprefixer.info", params_with_browsers)
|
55
54
|
end
|
56
55
|
|
57
56
|
# Parse Browserslist config
|
58
57
|
def parse_config(config)
|
59
|
-
sections = {"defaults" => []}
|
58
|
+
sections = { "defaults" => [] }
|
60
59
|
current = "defaults"
|
61
60
|
config.gsub(/#[^\n]*/, "")
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
.split(/\n/)
|
62
|
+
.map(&:strip)
|
63
|
+
.reject(&:empty?)
|
64
|
+
.each do |line|
|
66
65
|
if IS_SECTION =~ line
|
67
66
|
current = line.match(IS_SECTION)[1].strip
|
68
67
|
sections[current] ||= []
|
@@ -77,32 +76,25 @@ module AutoprefixerRails
|
|
77
76
|
|
78
77
|
def params_with_browsers(from = nil)
|
79
78
|
from ||= if defined?(Rails) && Rails.respond_to?(:root) && Rails.root
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
Rails.root.join("app/assets/stylesheets").to_s
|
80
|
+
else
|
81
|
+
"."
|
82
|
+
end
|
84
83
|
|
85
84
|
params = @params
|
86
|
-
if !params.key?(:browsers) && from
|
85
|
+
if !params.key?(:browsers) && !params.key?(:overrideBrowserslist) && from
|
87
86
|
file = find_config(from)
|
88
87
|
if file
|
89
88
|
env = params[:env].to_s || "development"
|
90
89
|
config = parse_config(file)
|
91
90
|
params = params.dup
|
92
|
-
params[:
|
91
|
+
params[:overrideBrowserslist] = (config[env] || config["defaults"])
|
93
92
|
end
|
94
93
|
end
|
95
94
|
|
96
95
|
params
|
97
96
|
end
|
98
97
|
|
99
|
-
# Convert params to JS string and add browsers from Browserslist config
|
100
|
-
def js_params
|
101
|
-
"{ " +
|
102
|
-
params_with_browsers.map { |k, v| "#{k}: #{v.inspect}"}.join(", ") +
|
103
|
-
" }"
|
104
|
-
end
|
105
|
-
|
106
98
|
# Convert ruby_options to jsOptions
|
107
99
|
def convert_options(opts)
|
108
100
|
converted = {}
|
@@ -138,57 +130,36 @@ module AutoprefixerRails
|
|
138
130
|
# Lazy load for JS library
|
139
131
|
def runtime
|
140
132
|
@runtime ||= begin
|
141
|
-
if ExecJS.eval("typeof Uint8Array") != "function"
|
142
|
-
if ExecJS.runtime.name.start_with?("therubyracer")
|
143
|
-
raise "ExecJS::RubyRacerRuntime is not supported. " \
|
144
|
-
"Please replace therubyracer with mini_racer " \
|
145
|
-
"in your Gemfile or use Node.js as ExecJS runtime."
|
146
|
-
else
|
147
|
-
raise "#{ExecJS.runtime.name} runtime does’t support ES6. " \
|
148
|
-
"Please update or replace your current ExecJS runtime."
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
if ExecJS.runtime == ExecJS::Runtimes::Node
|
153
|
-
version = ExecJS.runtime.eval("process.version")
|
154
|
-
first = version.match(/^v(\d+)/)[1].to_i
|
155
|
-
if first < 6
|
156
|
-
raise "Autoprefixer doesn’t support Node #{version}. Update it."
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
133
|
ExecJS.compile(build_js)
|
134
|
+
rescue ExecJS::RuntimeError
|
135
|
+
# Only complain about unsupported runtimes when it failed to parse our script.
|
136
|
+
|
137
|
+
case ExecJS.runtime
|
138
|
+
when ExecJS::Runtimes::Node
|
139
|
+
node_command = ExecJS.runtime.send(:binary) rescue "Unknown"
|
140
|
+
|
141
|
+
raise <<~MSG
|
142
|
+
Your nodejs binary failed to load autoprefixer script file,
|
143
|
+
please check if you're running a supported version (10, 12, 14+)
|
144
|
+
|
145
|
+
ENV["PATH"] = #{ENV["PATH"]}
|
146
|
+
binary = #{node_command}
|
147
|
+
MSG
|
148
|
+
when *SUPPORTED_RUNTIMES
|
149
|
+
raise
|
150
|
+
else
|
151
|
+
raise <<~MSG
|
152
|
+
Your ExecJS runtime #{ExecJS.runtime.name} isn't supported by autoprefixer-rails,
|
153
|
+
please switch to #{SUPPORTED_RUNTIMES.map(&:name).join(' or ')}
|
154
|
+
MSG
|
155
|
+
end
|
161
156
|
end
|
162
157
|
end
|
163
158
|
|
164
|
-
# Cache autoprefixer.js content
|
165
|
-
def read_js
|
166
|
-
@@js ||= begin
|
167
|
-
root = Pathname(File.dirname(__FILE__))
|
168
|
-
path = root.join("../../vendor/autoprefixer.js")
|
169
|
-
path.read
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
# Return processor JS with some extra methods
|
174
159
|
def build_js
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
# Return JS code for process method proxy
|
179
|
-
def process_proxy
|
180
|
-
<<-JS
|
181
|
-
var processor;
|
182
|
-
var process = function() {
|
183
|
-
var result = autoprefixer.process.apply(autoprefixer, arguments);
|
184
|
-
var warns = result.warnings().map(function (i) {
|
185
|
-
delete i.plugin;
|
186
|
-
return i.toString();
|
187
|
-
});
|
188
|
-
var map = result.map ? result.map.toString() : null;
|
189
|
-
return { css: result.css, map: map, warnings: warns };
|
190
|
-
};
|
191
|
-
JS
|
160
|
+
root = Pathname(File.dirname(__FILE__))
|
161
|
+
path = root.join("../../vendor/autoprefixer.js")
|
162
|
+
path.read
|
192
163
|
end
|
193
164
|
end
|
194
165
|
end
|
@@ -1,8 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "yaml"
|
4
|
+
begin
|
5
|
+
require "sprockets/railtie"
|
6
|
+
rescue LoadError
|
7
|
+
end
|
2
8
|
|
3
9
|
begin
|
4
10
|
module AutoprefixedRails
|
5
|
-
class Railtie < ::Rails::Railtie
|
11
|
+
class Railtie < ::Rails::Railtie # :nodoc:
|
6
12
|
rake_tasks do |app|
|
7
13
|
require "rake/autoprefixer_tasks"
|
8
14
|
Rake::AutoprefixerTasks.new(config) if defined? app.assets
|
@@ -14,9 +20,7 @@ begin
|
|
14
20
|
end
|
15
21
|
else
|
16
22
|
initializer :setup_autoprefixer, group: :all do |app|
|
17
|
-
if defined?(app.assets) && !app.assets.nil?
|
18
|
-
AutoprefixerRails.install(app.assets, config)
|
19
|
-
end
|
23
|
+
AutoprefixerRails.install(app.assets, config) if defined?(app.assets) && !app.assets.nil?
|
20
24
|
end
|
21
25
|
end
|
22
26
|
|
@@ -27,13 +31,14 @@ begin
|
|
27
31
|
roots.each do |root|
|
28
32
|
file = File.join(root, "config/autoprefixer.yml")
|
29
33
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
next unless File.exist?(file)
|
35
|
+
|
36
|
+
parsed = ::YAML.load_file(file)
|
37
|
+
next unless parsed
|
38
|
+
|
39
|
+
params = parsed
|
34
40
|
|
35
|
-
|
36
|
-
end
|
41
|
+
break
|
37
42
|
end
|
38
43
|
|
39
44
|
params = params.symbolize_keys
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "pathname"
|
2
4
|
|
3
5
|
module AutoprefixerRails
|
@@ -30,10 +32,10 @@ module AutoprefixerRails
|
|
30
32
|
def self.install(env)
|
31
33
|
if ::Sprockets::VERSION.to_f < 4
|
32
34
|
env.register_postprocessor("text/css",
|
33
|
-
|
35
|
+
::AutoprefixerRails::Sprockets)
|
34
36
|
else
|
35
37
|
env.register_bundle_processor("text/css",
|
36
|
-
|
38
|
+
::AutoprefixerRails::Sprockets)
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
@@ -41,10 +43,10 @@ module AutoprefixerRails
|
|
41
43
|
def self.uninstall(env)
|
42
44
|
if ::Sprockets::VERSION.to_f < 4
|
43
45
|
env.unregister_postprocessor("text/css",
|
44
|
-
|
46
|
+
::AutoprefixerRails::Sprockets)
|
45
47
|
else
|
46
48
|
env.unregister_bundle_processor("text/css",
|
47
|
-
|
49
|
+
::AutoprefixerRails::Sprockets)
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
@@ -55,7 +57,7 @@ module AutoprefixerRails
|
|
55
57
|
end
|
56
58
|
|
57
59
|
# Sprockets 2 API new and render
|
58
|
-
def render(
|
60
|
+
def render(*)
|
59
61
|
self.class.run(@filename, @source)
|
60
62
|
end
|
61
63
|
end
|
data/lib/autoprefixer-rails.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Ruby integration with Autoprefixer JS library, which parse CSS and adds
|
2
4
|
# only actual prefixed
|
3
5
|
module AutoprefixerRails
|
@@ -6,6 +8,7 @@ module AutoprefixerRails
|
|
6
8
|
# Add prefixes to `css`. See `Processor#process` for options.
|
7
9
|
def self.process(css, opts = {})
|
8
10
|
params = {}
|
11
|
+
params[:overrideBrowserslist] = opts.delete(:overrideBrowserslist) if opts.key?(:overrideBrowserslist)
|
9
12
|
params[:browsers] = opts.delete(:browsers) if opts.key?(:browsers)
|
10
13
|
params[:cascade] = opts.delete(:cascade) if opts.key?(:cascade)
|
11
14
|
params[:remove] = opts.delete(:remove) if opts.key?(:remove)
|