autoprefixer-rails 9.4.8 → 10.4.2.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 +4 -4
- data/CHANGELOG.md +185 -0
- data/README.md +25 -33
- data/lib/autoprefixer-rails/processor.rb +73 -109
- data/lib/autoprefixer-rails/railtie.rb +20 -15
- data/lib/autoprefixer-rails/result.rb +2 -0
- data/lib/autoprefixer-rails/sprockets.rb +16 -14
- data/lib/autoprefixer-rails/version.rb +4 -2
- data/lib/autoprefixer-rails.rb +16 -13
- data/lib/rake/autoprefixer_tasks.rb +6 -4
- data/vendor/autoprefixer.js +72694 -58965
- metadata +44 -49
- data/.gitignore +0 -7
- data/.rspec +0 -1
- data/.travis.yml +0 -25
- data/Gemfile +0 -9
- data/Rakefile +0 -48
- data/autoprefixer-rails.gemspec +0 -28
- 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 -14
- 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/compress.rb +0 -1
- 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/compass/config.rb +0 -34
- data/spec/compass/sass/screen.scss +0 -3
- data/spec/compass_spec.rb +0 -21
- data/spec/processor_spec.rb +0 -14
- data/spec/rails_spec.rb +0 -50
- data/spec/railtie_spec.rb +0 -29
- data/spec/spec_helper.rb +0 -16
- data/sprockets4.gemfile +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57c218760a92a4c4449c643e59d5c9b99d187c228aaa68c563d03c468fc2a055
|
4
|
+
data.tar.gz: fa282be312c5ad55816deb7475a3d2f3357266a806ac96a624f125f2f0d0fc4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f20ccf58b1661fe3082f9d0487979c42146b21115df430269ca6d7a3a35dfa2f44cb04c1f4f3eb01eaf00bd360f4823d00106101c38bb80a8c278e4d9b764ed4
|
7
|
+
data.tar.gz: beb69b97fb7f92d970fae59bfefff484b1f59973bfcf26b049ecbc738a61db9044e660040531b0f959cb50f17f6ec5412ee8b1f226ba30b0cec359e902ac9bfa
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,190 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 10.4.2.0
|
4
|
+
* Fixed missed `-webkit-` prefix for `width: stretch`.
|
5
|
+
* Fixed `::file-selector-button` data (by Luke Warlow).
|
6
|
+
* Ensure sprockets-rails is loaded before autoprefixer-rails (by Thomas Morgan)
|
7
|
+
|
8
|
+
## 10.4.0.0
|
9
|
+
* Added `:autofill` support (by Luke Warlow).
|
10
|
+
|
11
|
+
## 10.3.3.0
|
12
|
+
* Fixed `::file-selector-button` support (by Usman Yunusov).
|
13
|
+
* Fixed wrong `-moz-` prefix from `::file-selector-button` (by Usman Yunusov).
|
14
|
+
|
15
|
+
## 10.3.1.0
|
16
|
+
* Added `::file-selector-button` support (by Luke Warlow).
|
17
|
+
* Fixed adding wrong prefixes to `content` (by Luke Warlow).
|
18
|
+
* Fix `ReferenceError: Can't find variable: URL` (#213)
|
19
|
+
|
20
|
+
## 10.2.5.1
|
21
|
+
* Remove nodejs version check via ExecJS, to be compatible with 2.8.1 (#203)
|
22
|
+
|
23
|
+
## 10.2.5.0
|
24
|
+
* Fixed `:` support in `@supports` (by Dmitry Semigradsky).
|
25
|
+
* Update Can I Use data.
|
26
|
+
* Lock to execjs < 2.8.0 for now (#203)
|
27
|
+
|
28
|
+
## 10.2.4.0
|
29
|
+
* Fixed `transition-property` warnings (by @Sheraff).
|
30
|
+
|
31
|
+
## 10.2.0.0 "Sub rosa"
|
32
|
+
* Added TypeScript definitions (by Dmitry Semigradsky).
|
33
|
+
* Fixed docs (by Florian Pellet).
|
34
|
+
* Update Can I Use data.
|
35
|
+
* Update postcss to 8.2.2
|
36
|
+
|
37
|
+
## 10.1.0.0 "Pula"
|
38
|
+
* Fixed `Cannot read property 'proxyOf' of undefined` error (by Igor Kamyshev).
|
39
|
+
* Added `dpcm` unit support to `min-resolution: 2dppx` (by Robert Eisele).
|
40
|
+
* Fixed rational approximation in `min-resolution` (by Robert Eisele).
|
41
|
+
|
42
|
+
## 10.0.3.0
|
43
|
+
* Fixed `substract` to `subtract` value for `mask-composite` (by Michelle Enos).
|
44
|
+
* Update Can I Use data
|
45
|
+
|
46
|
+
## 10.0.2.0
|
47
|
+
* Removed -ms-user-select: all because IE and old Edge don’t support it.
|
48
|
+
* Fixed Grid Layout warning.
|
49
|
+
* Update Can I Use data
|
50
|
+
|
51
|
+
## 10.0.1.3
|
52
|
+
* Fix `fileURL.replace is not a function` when reporting warnings (#194)
|
53
|
+
|
54
|
+
## 10.0.1.2
|
55
|
+
* Workaround `existsSync not a function` (#193)
|
56
|
+
|
57
|
+
## 10.0.1.1
|
58
|
+
* Update Can I Use data.
|
59
|
+
* Update postcss to 8.1.4
|
60
|
+
* Fix issue with source map (#190)
|
61
|
+
|
62
|
+
## 10.0.1.0
|
63
|
+
* Update Can I Use data.
|
64
|
+
* Update autoprefixer to 10.0.1
|
65
|
+
* Update postcss to 8.1.1
|
66
|
+
|
67
|
+
## 10.0.0.2
|
68
|
+
* Update postcss to 8.0.5
|
69
|
+
* Update browserslist & caniuse-lite
|
70
|
+
|
71
|
+
## 10.0.0.1
|
72
|
+
* Improved error message for old environments.
|
73
|
+
* Reduced gem file size.
|
74
|
+
|
75
|
+
## 10.0 “Alis volat propriis”
|
76
|
+
* Removed support for Node.js 6.x, 8.x, 11.x.
|
77
|
+
* Moved to PostCSS 8.
|
78
|
+
|
79
|
+
## 9.8.6.5
|
80
|
+
* Fix `9.8.6.4` regression.
|
81
|
+
|
82
|
+
## 9.8.6.4
|
83
|
+
* Remove deprecation warnings.
|
84
|
+
|
85
|
+
## 9.8.6.3
|
86
|
+
* Fix deprecation warning for non-Rails environment.
|
87
|
+
|
88
|
+
## 9.8.6.2
|
89
|
+
* Print deprecation warning only once.
|
90
|
+
|
91
|
+
## 9.8.6.1
|
92
|
+
* Improve deprecated warnings.
|
93
|
+
|
94
|
+
## 9.8.6
|
95
|
+
* Fixed `env` option.
|
96
|
+
* Added deprecation warning.
|
97
|
+
|
98
|
+
## 9.8.5
|
99
|
+
* Improved Grid Layout warnings (by Daniel Tonon).
|
100
|
+
|
101
|
+
## 9.8.4
|
102
|
+
* Reduce JS bundle size.
|
103
|
+
|
104
|
+
## 9.8.3
|
105
|
+
* Update Can I Use data.
|
106
|
+
|
107
|
+
## 9.8.2
|
108
|
+
* Update Can I Use data.
|
109
|
+
|
110
|
+
## 9.8.1
|
111
|
+
* Replace `chalk` to `kleur` (by Luke Edwards).
|
112
|
+
|
113
|
+
## 9.8 “Vigilo Confido”
|
114
|
+
* Add `:placeholder-shown` support (by Tanguy Krotoff).
|
115
|
+
|
116
|
+
## 9.7.6
|
117
|
+
* Revert `-webkit-stretch` fix.
|
118
|
+
|
119
|
+
## 9.7.5
|
120
|
+
* Fix `-webkit-stretch` support.
|
121
|
+
* Reduce gem file size.
|
122
|
+
|
123
|
+
## 9.7.4
|
124
|
+
* Update Can I Use data.
|
125
|
+
|
126
|
+
## 9.7.3
|
127
|
+
* Update Can I Use data.
|
128
|
+
|
129
|
+
## 9.7.2
|
130
|
+
* Add `-ms-user-select: element` support.
|
131
|
+
|
132
|
+
## 9.7.1
|
133
|
+
* Avoid unnecessary transitions in prefixed selectors (by Andrey Alexandrov).
|
134
|
+
* Fix `fit-content` for Firefox.
|
135
|
+
|
136
|
+
## 9.7 “Ad Victoriam”
|
137
|
+
* Add `AUTOPREFIXER_GRID` env variable to enable Grid Layout polyfill for IE.
|
138
|
+
* Fix `Cannot read property 'grid' of undefined` error.
|
139
|
+
|
140
|
+
## 9.6.5
|
141
|
+
* Fix selector prefixing (by Andrey Alexandrov).
|
142
|
+
|
143
|
+
## 9.6.4
|
144
|
+
* Now the real fix for `'startsWith' of undefined` error.
|
145
|
+
|
146
|
+
## 9.6.3
|
147
|
+
* Fix `Cannot read property 'startsWith' of undefined` error.
|
148
|
+
|
149
|
+
## 9.6.2
|
150
|
+
* Fix false `Replace fill to stretch` warning.
|
151
|
+
|
152
|
+
## 9.6.1.1
|
153
|
+
* Update Can I Use data.
|
154
|
+
|
155
|
+
## 9.6.1
|
156
|
+
* Fix `-webkit-line-clamp` truncating multi-line text support.
|
157
|
+
|
158
|
+
## 9.6 “Nunc id vides, nunc ne vides”
|
159
|
+
* Add warning-less `overrideBrowserslist` option.
|
160
|
+
* Add `text-orientation` support.
|
161
|
+
* Add `min-resolution: 2x` alias support.
|
162
|
+
|
163
|
+
## 9.5.1.1
|
164
|
+
* Fix `register_postprocessor' for nil:NilClass` error.
|
165
|
+
* Update Can I Use data.
|
166
|
+
|
167
|
+
## 9.5.1
|
168
|
+
* Fix `backdrop-filter` for Edge (by Oleh Aloshkin).
|
169
|
+
* Fix `min-resolution` media query support in Firefox < 16.
|
170
|
+
|
171
|
+
## 9.5 “Draco dormiens nunquam titillandus”
|
172
|
+
* Add `mask-composite` support (by Semen Levenson).
|
173
|
+
|
174
|
+
## 9.4.10.2
|
175
|
+
* Fix Ruby < 2.4 support (by Jack Ford).
|
176
|
+
* Update Can I Use data.
|
177
|
+
|
178
|
+
## 9.4.10.1
|
179
|
+
* Fix non-Rails environments support (by Junya Ogura).
|
180
|
+
* Update Can I Use data.
|
181
|
+
|
182
|
+
## 9.4.10
|
183
|
+
* Add warning for named Grid rows.
|
184
|
+
|
185
|
+
## 9.4.9
|
186
|
+
* Fix `grid-template` and `@media` case (by Bogdan Dolin).
|
187
|
+
|
3
188
|
## 9.4.8
|
4
189
|
* Fix `calc()` support in Grid gap.
|
5
190
|
|
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,
|
@@ -244,3 +228,11 @@ to JS style, so you can use `map: { sources_content: false }`
|
|
244
228
|
instead of camelcase `sourcesContent`.
|
245
229
|
|
246
230
|
[PostCSS docs]: https://github.com/postcss/postcss#source-map-1
|
231
|
+
|
232
|
+
|
233
|
+
## Security Contact
|
234
|
+
|
235
|
+
To report a security vulnerability, please use the [Tidelift security contact].
|
236
|
+
Tidelift will coordinate the fix and disclosure.
|
237
|
+
|
238
|
+
[Tidelift security contact]: https://tidelift.com/security
|
@@ -1,15 +1,18 @@
|
|
1
|
-
|
2
|
-
require 'execjs'
|
3
|
-
require 'json'
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
|
3
|
+
require "pathname"
|
4
|
+
require "execjs"
|
5
|
+
require "json"
|
6
|
+
|
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]
|
10
13
|
|
11
|
-
def initialize(params = {
|
12
|
-
@params = params || {
|
14
|
+
def initialize(params = {})
|
15
|
+
@params = params || {}
|
13
16
|
end
|
14
17
|
|
15
18
|
# Process `css` and return result.
|
@@ -18,105 +21,87 @@ module AutoprefixerRails
|
|
18
21
|
# * `from` with input CSS file name. Will be used in error messages.
|
19
22
|
# * `to` with output CSS file name.
|
20
23
|
# * `map` with true to generate new source map or with previous map.
|
21
|
-
def process(css, opts = {
|
24
|
+
def process(css, opts = {})
|
22
25
|
opts = convert_options(opts)
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
pluginOpts = params_with_browsers(opts[:from]).merge(opts)
|
30
|
-
processOpts = {
|
31
|
-
from: pluginOpts.delete(:from),
|
32
|
-
to: pluginOpts.delete(:to),
|
33
|
-
map: pluginOpts.delete(:map)
|
27
|
+
plugin_opts = params_with_browsers(opts[:from]).merge(opts)
|
28
|
+
process_opts = {
|
29
|
+
from: plugin_opts.delete(:from),
|
30
|
+
to: plugin_opts.delete(:to),
|
31
|
+
map: plugin_opts.delete(:map)
|
34
32
|
}
|
35
33
|
|
36
34
|
begin
|
37
|
-
result = runtime.call(
|
35
|
+
result = runtime.call("autoprefixer.process", css, process_opts, plugin_opts)
|
38
36
|
rescue ExecJS::ProgramError => e
|
39
|
-
contry_error =
|
40
|
-
|
41
|
-
|
37
|
+
contry_error = "BrowserslistError: " \
|
38
|
+
"Country statistics are not supported " \
|
39
|
+
"in client-side build of Browserslist"
|
42
40
|
if e.message == contry_error
|
43
|
-
raise
|
44
|
-
|
41
|
+
raise "Country statistics is not supported in AutoprefixerRails. " \
|
42
|
+
"Use Autoprefixer with webpack or other Node.js builder."
|
45
43
|
else
|
46
44
|
raise e
|
47
45
|
end
|
48
46
|
end
|
49
47
|
|
50
|
-
Result.new(result[
|
48
|
+
Result.new(result["css"], result["map"], result["warnings"])
|
51
49
|
end
|
52
50
|
|
53
51
|
# Return, which browsers and prefixes will be used
|
54
52
|
def info
|
55
|
-
runtime.
|
53
|
+
runtime.call("autoprefixer.info", params_with_browsers)
|
56
54
|
end
|
57
55
|
|
58
56
|
# Parse Browserslist config
|
59
57
|
def parse_config(config)
|
60
|
-
sections = {
|
61
|
-
current =
|
62
|
-
config.gsub(/#[^\n]*/,
|
58
|
+
sections = { "defaults" => [] }
|
59
|
+
current = "defaults"
|
60
|
+
config.gsub(/#[^\n]*/, "")
|
63
61
|
.split(/\n/)
|
64
62
|
.map(&:strip)
|
65
63
|
.reject(&:empty?)
|
66
64
|
.each do |line|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
65
|
+
if IS_SECTION =~ line
|
66
|
+
current = line.match(IS_SECTION)[1].strip
|
67
|
+
sections[current] ||= []
|
68
|
+
else
|
69
|
+
sections[current] << line
|
70
|
+
end
|
71
|
+
end
|
74
72
|
sections
|
75
73
|
end
|
76
74
|
|
77
75
|
private
|
78
76
|
|
79
77
|
def params_with_browsers(from = nil)
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
86
|
-
end
|
78
|
+
from ||= if defined?(Rails) && Rails.respond_to?(:root) && Rails.root
|
79
|
+
Rails.root.join("app/assets/stylesheets").to_s
|
80
|
+
else
|
81
|
+
"."
|
82
|
+
end
|
87
83
|
|
88
84
|
params = @params
|
89
|
-
if
|
85
|
+
if !params.key?(:browsers) && !params.key?(:overrideBrowserslist) && from
|
90
86
|
file = find_config(from)
|
91
87
|
if file
|
92
|
-
env = params[:env].to_s ||
|
88
|
+
env = params[:env].to_s || "development"
|
93
89
|
config = parse_config(file)
|
94
90
|
params = params.dup
|
95
|
-
|
96
|
-
params[:browsers] = config[env]
|
97
|
-
else
|
98
|
-
params[:browsers] = config['defaults']
|
99
|
-
end
|
91
|
+
params[:overrideBrowserslist] = (config[env] || config["defaults"])
|
100
92
|
end
|
101
93
|
end
|
102
94
|
|
103
95
|
params
|
104
96
|
end
|
105
97
|
|
106
|
-
# Convert params to JS string and add browsers from Browserslist config
|
107
|
-
def js_params
|
108
|
-
'{ ' +
|
109
|
-
params_with_browsers.map { |k, v| "#{k}: #{v.inspect}"}.join(', ') +
|
110
|
-
' }'
|
111
|
-
end
|
112
|
-
|
113
98
|
# Convert ruby_options to jsOptions
|
114
99
|
def convert_options(opts)
|
115
|
-
converted = {
|
100
|
+
converted = {}
|
116
101
|
|
117
102
|
opts.each_pair do |name, value|
|
118
|
-
if
|
119
|
-
name = name.to_s.gsub(/_\w/) { |i| i.
|
103
|
+
if /_/ =~ name
|
104
|
+
name = name.to_s.gsub(/_\w/) { |i| i.delete("_").upcase }.to_sym
|
120
105
|
end
|
121
106
|
value = convert_options(value) if value.is_a? Hash
|
122
107
|
converted[name] = value
|
@@ -130,11 +115,11 @@ module AutoprefixerRails
|
|
130
115
|
path = Pathname(file).expand_path
|
131
116
|
|
132
117
|
while path.parent != path
|
133
|
-
config1 = path.join(
|
134
|
-
return config1.read if config1.exist?
|
118
|
+
config1 = path.join("browserslist")
|
119
|
+
return config1.read if config1.exist? && !config1.directory?
|
135
120
|
|
136
|
-
config2 = path.join(
|
137
|
-
return config2.read if config2.exist?
|
121
|
+
config2 = path.join(".browserslistrc")
|
122
|
+
return config2.read if config2.exist? && !config1.directory?
|
138
123
|
|
139
124
|
path = path.parent
|
140
125
|
end
|
@@ -145,57 +130,36 @@ module AutoprefixerRails
|
|
145
130
|
# Lazy load for JS library
|
146
131
|
def runtime
|
147
132
|
@runtime ||= begin
|
148
|
-
if ExecJS.eval('typeof Uint8Array') != 'function'
|
149
|
-
if ExecJS.runtime.name.start_with?('therubyracer')
|
150
|
-
raise "ExecJS::RubyRacerRuntime is not supported. " +
|
151
|
-
"Please replace therubyracer with mini_racer " +
|
152
|
-
"in your Gemfile or use Node.js as ExecJS runtime."
|
153
|
-
else
|
154
|
-
raise "#{ExecJS.runtime.name} runtime does’t support ES6. " +
|
155
|
-
"Please update or replace your current ExecJS runtime."
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
if ExecJS.runtime == ExecJS::Runtimes::Node
|
160
|
-
version = ExecJS.runtime.eval('process.version')
|
161
|
-
first = version.match(/^v(\d+)/)[1].to_i
|
162
|
-
if first < 6
|
163
|
-
raise "Autoprefixer doesn’t support Node #{ version }. Update it."
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
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
|
168
156
|
end
|
169
157
|
end
|
170
158
|
|
171
|
-
# Cache autoprefixer.js content
|
172
|
-
def read_js
|
173
|
-
@@js ||= begin
|
174
|
-
root = Pathname(File.dirname(__FILE__))
|
175
|
-
path = root.join("../../vendor/autoprefixer.js")
|
176
|
-
path.read
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
# Return processor JS with some extra methods
|
181
159
|
def build_js
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
# Return JS code for process method proxy
|
186
|
-
def process_proxy
|
187
|
-
<<-JS
|
188
|
-
var processor;
|
189
|
-
var process = function() {
|
190
|
-
var result = autoprefixer.process.apply(autoprefixer, arguments);
|
191
|
-
var warns = result.warnings().map(function (i) {
|
192
|
-
delete i.plugin;
|
193
|
-
return i.toString();
|
194
|
-
});
|
195
|
-
var map = result.map ? result.map.toString() : null;
|
196
|
-
return { css: result.css, map: map, warnings: warns };
|
197
|
-
};
|
198
|
-
JS
|
160
|
+
root = Pathname(File.dirname(__FILE__))
|
161
|
+
path = root.join("../../vendor/autoprefixer.js")
|
162
|
+
path.read
|
199
163
|
end
|
200
164
|
end
|
201
165
|
end
|
@@ -1,22 +1,26 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
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
|
-
require
|
8
|
-
Rake::AutoprefixerTasks.new(
|
13
|
+
require "rake/autoprefixer_tasks"
|
14
|
+
Rake::AutoprefixerTasks.new(config) if defined? app.assets
|
9
15
|
end
|
10
16
|
|
11
|
-
if config.respond_to?(:assets)
|
17
|
+
if config.respond_to?(:assets) && !config.assets.nil?
|
12
18
|
config.assets.configure do |env|
|
13
19
|
AutoprefixerRails.install(env, config)
|
14
20
|
end
|
15
21
|
else
|
16
22
|
initializer :setup_autoprefixer, group: :all do |app|
|
17
|
-
if defined?
|
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
|
|
@@ -25,15 +29,16 @@ begin
|
|
25
29
|
params = {}
|
26
30
|
|
27
31
|
roots.each do |root|
|
28
|
-
file = File.join(root,
|
32
|
+
file = File.join(root, "config/autoprefixer.yml")
|
33
|
+
|
34
|
+
next unless File.exist?(file)
|
35
|
+
|
36
|
+
parsed = ::YAML.load_file(file)
|
37
|
+
next unless parsed
|
29
38
|
|
30
|
-
|
31
|
-
parsed = ::YAML.load_file(file)
|
32
|
-
next unless parsed
|
33
|
-
params = parsed
|
39
|
+
params = parsed
|
34
40
|
|
35
|
-
|
36
|
-
end
|
41
|
+
break
|
37
42
|
end
|
38
43
|
|
39
44
|
params = params.symbolize_keys
|