autoprefixer-rails 8.6.5 → 9.6.1.1
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/.github/FUNDING.yml +1 -0
- data/.standard.yml +1 -0
- data/.travis.yml +7 -24
- data/CHANGELOG.md +118 -0
- data/Gemfile +10 -1
- data/README.md +27 -27
- data/Rakefile +25 -20
- data/autoprefixer-rails.gemspec +21 -17
- data/lib/autoprefixer-rails.rb +16 -13
- data/lib/autoprefixer-rails/processor.rb +71 -141
- data/lib/autoprefixer-rails/railtie.rb +6 -6
- data/lib/autoprefixer-rails/sprockets.rb +9 -9
- data/lib/autoprefixer-rails/version.rb +1 -1
- data/lib/rake/autoprefixer_tasks.rb +4 -4
- data/spec/app/Rakefile +1 -1
- data/spec/app/app/controllers/css_controller.rb +1 -1
- data/spec/app/config.ru +1 -1
- data/spec/app/config/application.rb +6 -4
- data/spec/app/config/boot.rb +2 -2
- data/spec/app/config/environment.rb +2 -2
- data/spec/app/config/initializers/secret_token.rb +1 -1
- data/spec/app/config/routes.rb +1 -1
- data/spec/autoprefixer_spec.rb +46 -37
- data/spec/processor_spec.rb +16 -5
- data/spec/rails_spec.rb +12 -22
- data/spec/railtie_spec.rb +9 -9
- data/spec/spec_helper.rb +5 -5
- data/vendor/autoprefixer.js +58064 -15703
- metadata +13 -17
- data/mini_racer.gemfile +0 -16
- data/shared.gemfile +0 -7
- data/spec/app/config/initializers/compress.rb +0 -1
- data/spec/compass/config.rb +0 -34
- data/spec/compass/sass/screen.scss +0 -3
- data/spec/compass_spec.rb +0 -21
- data/sprockets3.gemfile +0 -9
- data/sprockets4.gemfile +0 -9
@@ -1,20 +1,20 @@
|
|
1
|
-
require
|
1
|
+
require "yaml"
|
2
2
|
|
3
3
|
begin
|
4
4
|
module AutoprefixedRails
|
5
5
|
class Railtie < ::Rails::Railtie
|
6
6
|
rake_tasks do |app|
|
7
|
-
require
|
8
|
-
Rake::AutoprefixerTasks.new(
|
7
|
+
require "rake/autoprefixer_tasks"
|
8
|
+
Rake::AutoprefixerTasks.new(config) if defined? app.assets
|
9
9
|
end
|
10
10
|
|
11
|
-
if config.respond_to?(:assets)
|
11
|
+
if config.respond_to?(:assets) && !config.assets.nil?
|
12
12
|
config.assets.configure do |env|
|
13
13
|
AutoprefixerRails.install(env, config)
|
14
14
|
end
|
15
15
|
else
|
16
16
|
initializer :setup_autoprefixer, group: :all do |app|
|
17
|
-
if defined?
|
17
|
+
if defined?(app.assets) && !app.assets.nil?
|
18
18
|
AutoprefixerRails.install(app.assets, config)
|
19
19
|
end
|
20
20
|
end
|
@@ -25,7 +25,7 @@ begin
|
|
25
25
|
params = {}
|
26
26
|
|
27
27
|
roots.each do |root|
|
28
|
-
file = File.join(root,
|
28
|
+
file = File.join(root, "config/autoprefixer.yml")
|
29
29
|
|
30
30
|
if File.exist?(file)
|
31
31
|
parsed = ::YAML.load_file(file)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "pathname"
|
2
2
|
|
3
3
|
module AutoprefixerRails
|
4
4
|
# Register autoprefixer postprocessor in Sprockets and fix common issues
|
@@ -16,11 +16,11 @@ module AutoprefixerRails
|
|
16
16
|
|
17
17
|
# Add prefixes to `css`
|
18
18
|
def self.run(filename, css)
|
19
|
-
output = filename.chomp(File.extname(filename)) +
|
19
|
+
output = filename.chomp(File.extname(filename)) + ".css"
|
20
20
|
result = @processor.process(css, from: filename, to: output)
|
21
21
|
|
22
22
|
result.warnings.each do |warning|
|
23
|
-
|
23
|
+
warn "autoprefixer: #{warning}"
|
24
24
|
end
|
25
25
|
|
26
26
|
result.css
|
@@ -29,10 +29,10 @@ module AutoprefixerRails
|
|
29
29
|
# Register postprocessor in Sprockets depend on issues with other gems
|
30
30
|
def self.install(env)
|
31
31
|
if ::Sprockets::VERSION.to_f < 4
|
32
|
-
env.register_postprocessor(
|
32
|
+
env.register_postprocessor("text/css",
|
33
33
|
::AutoprefixerRails::Sprockets)
|
34
34
|
else
|
35
|
-
env.register_bundle_processor(
|
35
|
+
env.register_bundle_processor("text/css",
|
36
36
|
::AutoprefixerRails::Sprockets)
|
37
37
|
end
|
38
38
|
end
|
@@ -40,18 +40,18 @@ module AutoprefixerRails
|
|
40
40
|
# Register postprocessor in Sprockets depend on issues with other gems
|
41
41
|
def self.uninstall(env)
|
42
42
|
if ::Sprockets::VERSION.to_f < 4
|
43
|
-
env.unregister_postprocessor(
|
43
|
+
env.unregister_postprocessor("text/css",
|
44
44
|
::AutoprefixerRails::Sprockets)
|
45
45
|
else
|
46
|
-
env.unregister_bundle_processor(
|
46
|
+
env.unregister_bundle_processor("text/css",
|
47
47
|
::AutoprefixerRails::Sprockets)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
# Sprockets 2 API new and render
|
52
|
-
def initialize(filename
|
52
|
+
def initialize(filename)
|
53
53
|
@filename = filename
|
54
|
-
@source =
|
54
|
+
@source = yield
|
55
55
|
end
|
56
56
|
|
57
57
|
# Sprockets 2 API new and render
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "rake"
|
2
|
+
require "rake/tasklib"
|
3
|
+
require "autoprefixer-rails"
|
4
4
|
|
5
5
|
module Rake
|
6
6
|
# Define task to inspect Autoprefixer browsers, properties and values.
|
@@ -18,7 +18,7 @@ module Rake
|
|
18
18
|
|
19
19
|
def define
|
20
20
|
namespace :autoprefixer do
|
21
|
-
desc
|
21
|
+
desc "Show selected browsers and prefixed CSS properties and values"
|
22
22
|
task :info do
|
23
23
|
puts @processor.info
|
24
24
|
end
|
data/spec/app/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../config/application", __FILE__)
|
2
2
|
App::Application.load_tasks
|
data/spec/app/config.ru
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require ::File.expand_path(
|
1
|
+
require ::File.expand_path("../config/environment", __FILE__)
|
2
2
|
run App::Application
|
@@ -1,14 +1,16 @@
|
|
1
|
-
require File.expand_path(
|
1
|
+
require File.expand_path("../boot", __FILE__)
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "action_controller/railtie"
|
4
|
+
require "sprockets/railtie"
|
5
5
|
|
6
6
|
if defined?(Bundler)
|
7
|
-
Bundler.require(*Rails.groups(assets: %w
|
7
|
+
Bundler.require(*Rails.groups(assets: %w[development test]))
|
8
8
|
end
|
9
9
|
|
10
10
|
module App
|
11
11
|
class Application < Rails::Application
|
12
12
|
config.assets.enabled = true
|
13
|
+
config.sass.line_comments = false
|
14
|
+
config.sass.inline_source_maps = true
|
13
15
|
end
|
14
16
|
end
|
data/spec/app/config/boot.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
ENV[
|
2
|
-
require
|
1
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../../Gemfile", __FILE__)
|
2
|
+
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
|
@@ -1,3 +1,3 @@
|
|
1
|
-
require
|
2
|
-
require File.expand_path(
|
1
|
+
require "tzinfo"
|
2
|
+
require File.expand_path("../application", __FILE__)
|
3
3
|
App::Application.initialize!
|
@@ -1 +1 @@
|
|
1
|
-
App::Application.config.secret_key_base =
|
1
|
+
App::Application.config.secret_key_base = "test"
|
data/spec/app/config/routes.rb
CHANGED
data/spec/autoprefixer_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "spec_helper"
|
2
2
|
|
3
3
|
describe AutoprefixerRails do
|
4
4
|
before :all do
|
5
5
|
@dir = Pathname(__FILE__).dirname
|
6
|
-
@css = @dir.join(
|
6
|
+
@css = @dir.join("app/app/assets/stylesheets/test.css").read
|
7
7
|
end
|
8
8
|
|
9
9
|
it "process CSS" do
|
@@ -12,101 +12,110 @@ describe AutoprefixerRails do
|
|
12
12
|
|
13
13
|
it "process CSS for selected browsers" do
|
14
14
|
css = "a {\n tab-size: 2\n}"
|
15
|
-
result = AutoprefixerRails.process(css,
|
16
|
-
expect(result.css).to eq "a {\n"
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
result = AutoprefixerRails.process(css, overrideBrowserslist: ["opera 12"])
|
16
|
+
expect(result.css).to eq "a {\n" \
|
17
|
+
" -o-tab-size: 2;\n" \
|
18
|
+
" tab-size: 2\n" \
|
19
|
+
"}"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "has browsers option" do
|
23
|
+
css = "a {\n tab-size: 2\n}"
|
24
|
+
result = AutoprefixerRails.process(css, browsers: ["opera 12"])
|
25
|
+
expect(result.css).to eq "a {\n" \
|
26
|
+
" -o-tab-size: 2;\n" \
|
27
|
+
" tab-size: 2\n" \
|
28
|
+
"}"
|
20
29
|
end
|
21
30
|
|
22
31
|
it "process @supports" do
|
23
32
|
css = "@supports (display: flex) { }"
|
24
|
-
result = AutoprefixerRails.process(css,
|
33
|
+
result = AutoprefixerRails.process(css, overrideBrowserslist: ["chrome 28"])
|
25
34
|
expect(result.css).to eq(
|
26
|
-
|
35
|
+
"@supports ((display: -webkit-flex) or (display: flex)) { }"
|
36
|
+
)
|
27
37
|
end
|
28
38
|
|
29
39
|
it "generates source map" do
|
30
40
|
result = AutoprefixerRails.process(@css, map: true)
|
31
|
-
expect(result.css).to include(
|
41
|
+
expect(result.css).to include("/*# sourceMappingURL=data:")
|
32
42
|
end
|
33
43
|
|
34
44
|
it "generates separated source map" do
|
35
|
-
result = AutoprefixerRails.process(@css, map: {
|
45
|
+
result = AutoprefixerRails.process(@css, map: {inline: false})
|
36
46
|
expect(result.map).to be_a(String)
|
37
47
|
end
|
38
48
|
|
39
49
|
it "uses file name in syntax errors", not_jruby: true do
|
40
50
|
expect {
|
41
|
-
AutoprefixerRails.process(
|
51
|
+
AutoprefixerRails.process("a {", from: "a.css")
|
42
52
|
}.to raise_error(/a.css:/)
|
43
53
|
end
|
44
54
|
|
45
55
|
it "includes sourcesContent by default" do
|
46
|
-
map = AutoprefixerRails.process(
|
47
|
-
expect(map).to include(
|
56
|
+
map = AutoprefixerRails.process("a{}", map: {inline: false}).map
|
57
|
+
expect(map).to include("sourcesContent")
|
48
58
|
end
|
49
59
|
|
50
60
|
it "maps options from Ruby style" do
|
51
|
-
map = AutoprefixerRails.process(
|
61
|
+
map = AutoprefixerRails.process("a{}", map: {
|
52
62
|
sources_content: false,
|
53
|
-
inline:
|
63
|
+
inline: false,
|
54
64
|
}).map
|
55
65
|
|
56
|
-
expect(map).not_to include(
|
66
|
+
expect(map).not_to include("sourcesContent")
|
57
67
|
end
|
58
68
|
|
59
69
|
it "does not remove old prefixes on request" do
|
60
|
-
css =
|
70
|
+
css = "a { -moz-border-radius: 5px; border-radius: 5px }"
|
61
71
|
result = AutoprefixerRails.process(css, remove: false)
|
62
72
|
expect(result.css).to eq(css)
|
63
73
|
end
|
64
74
|
|
65
75
|
it "shows debug" do
|
66
|
-
info = AutoprefixerRails.processor(
|
76
|
+
info = AutoprefixerRails.processor(overrideBrowserslist: ["chrome 25"]).info
|
67
77
|
expect(info).to match(/Browsers:\n Chrome: 25\n\n/)
|
68
78
|
expect(info).to match(/ transition: webkit/)
|
69
79
|
end
|
70
80
|
|
71
81
|
it "returns warnings" do
|
72
|
-
css =
|
82
|
+
css = "a{background:linear-gradient(top,white,black)}"
|
73
83
|
result = AutoprefixerRails.process(css)
|
74
|
-
expect(result.warnings).to eq([
|
75
|
-
|
84
|
+
expect(result.warnings).to eq(["<css input>:1:3: Gradient has outdated " \
|
85
|
+
"direction syntax. New syntax is like `to left` instead of `right`."])
|
76
86
|
end
|
77
87
|
|
78
88
|
it "shows correct error on country statistics" do
|
79
89
|
expect {
|
80
|
-
AutoprefixerRails.process(
|
90
|
+
AutoprefixerRails.process("", overrideBrowserslist: "> 1% in US")
|
81
91
|
}.to raise_error(/Use Autoprefixer with webpack/)
|
82
92
|
end
|
83
93
|
|
84
|
-
context
|
94
|
+
context "Sprockets" do
|
85
95
|
before :each do
|
86
96
|
@assets = Sprockets::Environment.new
|
87
|
-
@assets.append_path(@dir.join(
|
88
|
-
AutoprefixerRails.install(@assets,
|
97
|
+
@assets.append_path(@dir.join("app/app/assets/stylesheets"))
|
98
|
+
AutoprefixerRails.install(@assets, overrideBrowserslist: ["chrome 25"])
|
89
99
|
end
|
90
100
|
|
91
101
|
it "integrates with Sprockets" do
|
92
|
-
css = @assets[
|
93
|
-
expect(css).to eq "a {\n"
|
94
|
-
|
95
|
-
|
96
|
-
|
102
|
+
css = @assets["test.css"].to_s
|
103
|
+
expect(css).to eq "a {\n" \
|
104
|
+
" -webkit-mask: none;\n" \
|
105
|
+
" mask: none\n" \
|
106
|
+
"}\n"
|
97
107
|
end
|
98
108
|
|
99
109
|
it "shows file name from Sprockets", not_jruby: true do
|
100
|
-
expect { @assets[
|
110
|
+
expect { @assets["wrong.css"] }.to raise_error(/wrong/)
|
101
111
|
end
|
102
112
|
|
103
113
|
it "supports disabling", not_jruby: true do
|
104
114
|
AutoprefixerRails.uninstall(@assets)
|
105
|
-
css = @assets[
|
106
|
-
expect(css).to eq "a {\n"
|
107
|
-
|
108
|
-
|
115
|
+
css = @assets["test.css"].to_s
|
116
|
+
expect(css).to eq "a {\n" \
|
117
|
+
" mask: none\n" \
|
118
|
+
"}\n"
|
109
119
|
end
|
110
|
-
|
111
120
|
end
|
112
121
|
end
|
data/spec/processor_spec.rb
CHANGED
@@ -1,14 +1,25 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "spec_helper"
|
2
2
|
|
3
3
|
describe AutoprefixerRails::Processor do
|
4
|
-
|
5
|
-
it 'parses config' do
|
4
|
+
it "parses config" do
|
6
5
|
config = "# Comment\n ie 11\n \nie 8 # sorry\n[test ]\nios 8"
|
7
6
|
processor = AutoprefixerRails::Processor.new
|
8
7
|
expect(processor.parse_config(config)).to eql({
|
9
|
-
|
10
|
-
|
8
|
+
"defaults" => ["ie 11", "ie 8"],
|
9
|
+
"test" => ["ios 8"],
|
11
10
|
})
|
12
11
|
end
|
13
12
|
|
13
|
+
context "without Rails" do
|
14
|
+
before do
|
15
|
+
hide_const("Rails")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "doesn't raise error during processing" do
|
19
|
+
processor = AutoprefixerRails::Processor.new
|
20
|
+
expect {
|
21
|
+
processor.process("")
|
22
|
+
}.not_to raise_error
|
23
|
+
end
|
24
|
+
end
|
14
25
|
end
|
data/spec/rails_spec.rb
CHANGED
@@ -1,47 +1,37 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "spec_helper"
|
2
2
|
|
3
3
|
describe CssController, type: :controller do
|
4
4
|
before :all do
|
5
|
-
cache = Rails.root.join(
|
5
|
+
cache = Rails.root.join("tmp/cache")
|
6
6
|
cache.rmtree if cache.exist?
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_file(file)
|
10
|
-
if Rails.version.split(
|
11
|
-
get :test, params: {
|
10
|
+
if Rails.version.split(".").first.to_i >= 5
|
11
|
+
get :test, params: {file: file}
|
12
12
|
else
|
13
13
|
get :test, file: file
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
it "integrates with Rails and Sass" do
|
18
|
-
test_file
|
18
|
+
test_file "sass"
|
19
19
|
expect(response).to be_successful
|
20
|
-
clear_css = response.body.
|
21
|
-
expect(clear_css).to eq "a
|
20
|
+
clear_css = response.body.tr("\n", " ").squeeze(" ").strip
|
21
|
+
expect(clear_css).to eq "a{-webkit-mask:none;mask:none}"
|
22
22
|
end
|
23
23
|
|
24
24
|
if Sprockets::Context.instance_methods.include?(:evaluate)
|
25
|
-
it
|
26
|
-
test_file
|
25
|
+
it "supports evaluate" do
|
26
|
+
test_file "evaluate"
|
27
27
|
expect(response).to be_successful
|
28
|
-
clear_css = response.body.
|
29
|
-
expect(clear_css).to eq
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
if sprockets_4?
|
34
|
-
it "works with sprockets 4 source maps" do
|
35
|
-
get :test, params: { exact_file: 'sass.css.map' }
|
36
|
-
expect(response).to be_successful
|
37
|
-
|
38
|
-
source_map = JSON.parse(response.body)['sections'].first['map']
|
39
|
-
expect(source_map['sources'].first).to match(/loaded.*.sass/)
|
28
|
+
clear_css = response.body.tr("\n", " ").squeeze(" ").strip
|
29
|
+
expect(clear_css).to eq "a { -webkit-mask: none; mask: none }"
|
40
30
|
end
|
41
31
|
end
|
42
32
|
end
|
43
33
|
|
44
|
-
describe
|
34
|
+
describe "Rake task" do
|
45
35
|
it "shows debug" do
|
46
36
|
info = `cd spec/app; bundle exec rake autoprefixer:info`
|
47
37
|
expect(info).to match(/Browsers:\n Chrome: 25\n\n/)
|
data/spec/railtie_spec.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "spec_helper"
|
2
2
|
|
3
3
|
describe AutoprefixedRails::Railtie do
|
4
4
|
before do
|
5
5
|
@railtie = AutoprefixedRails::Railtie.instance
|
6
6
|
end
|
7
7
|
|
8
|
-
context
|
9
|
-
it
|
10
|
-
expect(@railtie.config).to eq(cascade: false, supports: false, env:
|
8
|
+
context "with config/autoprefixer.yml" do
|
9
|
+
it "works" do
|
10
|
+
expect(@railtie.config).to eq(cascade: false, supports: false, env: "test")
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
context
|
14
|
+
context "with empty config/autoprefixer.yml" do
|
15
15
|
before do
|
16
|
-
file_path = File.join(Rails.application.root,
|
16
|
+
file_path = File.join(Rails.application.root, "config/autoprefixer.yml")
|
17
17
|
allow(File).to receive(:exists?).with(file_path) { true }
|
18
18
|
allow(::YAML).to receive(:load_file).with(file_path) { false } # empty yaml
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
21
|
+
it "skips empty YAML" do
|
22
22
|
expect { @railtie.config }.not_to raise_error
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
expect(@railtie.config).to eq(env:
|
25
|
+
it "works" do
|
26
|
+
expect(@railtie.config).to eq(env: "test")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|