ai/autoprefixer-rails — 1.2k★ trên GitHub (Ruby). Autoprefixer for Ruby and Ruby on Rails
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Autoprefixer is a tool to parse CSS and add vendor prefixes to CSS rules
using values from the Can I Use database. This gem provides Ruby
and Ruby on Rails integration with this JavaScript tool.
Differences
The best way to use Autoprefixer is with webpack or Gulp.
Autoprefixer Rails doesn’t support these Autoprefixer features:
Browsers in package.json.
Custom browsers usage statistics.
Usage
Windows users should install Node.js. Autoprefixer Rails doesn’t work with
old JScript in Windows.
Autoprefixer Rails uses ExecJS that will use the best available JavaScript
runtime. Currently this gem is tested to work with Node.js version 10 and up
and with mini_racer, but will not work with therubyracer.
Ruby on Rails
Add the autoprefixer-rails gem to your Gemfile:
gem "autoprefixer-rails"
Clear your cache:
rake tmp:clear
Write your CSS (Sass, Stylus, LESS) rules without vendor prefixes
and Autoprefixer will apply prefixes for you.
For example in app/assets/stylesheet/foobar.sass:
:fullscreen a
display: flex
Autoprefixer uses the Can I Use database with browser statistics and properties
support to add vendor prefixes automatically using the Asset Pipeline:
:-webkit-full-screen a {
display: -webkit-box;
display: -webkit-flex;
display: flex
}
:-moz-full-screen a {
display: flex
}
:-ms-fullscreen a {
display: -ms-flexbox;
display: flex
}
:fullscreen a {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex
}
If you need to specify browsers for your Rails project, you can save them
to .browserslistrc and place it under app/assets/stylesheets/
or any of its ancestor directories
> 1%
last 2 versions
IE > 8 # comment
See Browserslist docs for config format. But > 5% in US query is not
supported in Rails, because of ExecJS limitations. You should migrate to webpack
or Gulp if you want it.
Note: you have to clear cache (rake tmp:clear) for the configuration
to take effect.
You can get what properties will be changed using a Rake task:
rake autoprefixer:info
To disable Autoprefixer just remove postprocessor:
If you use Sinatra or another non-Rails framework with Sprockets,
just connect your Sprockets environment with Autoprefixer and write CSS
in the usual way:
assets = Sprockets::Environment.new do |env|
# Your assets settings
end
require "autoprefixer-rails"
AutoprefixerRails.install(assets)
Ruby
If you need to call Autoprefixer from plain Ruby code, it’s very easy:
You should consider using Gulp instead of Compass binary,
because it has better Autoprefixer integration and many other awesome plugins.
But if you can’t move from Compass binary right now, there’s a hack
to run Autoprefixer after compass compile.
Install autoprefixer-rails gem:
gem install autoprefixer-rails
and add post-compile hook to config.rb:
require 'autoprefixer-rails'
on_stylesheet_saved do |file|
css = File.read(file)
map = file + '.map'
if File.exists? map
result = AutoprefixerRails.process(css,
from: file,
to: file,
map: { prev: File.read(map), inline: false })
File.open(file, 'w') { |io| io << result.css }
File.open(map, 'w') { |io| io << result.map }
else
File.open(file, 'w') { |io| io << AutoprefixerRails.process(css) }
end
end
Visual Cascade
By default, Autoprefixer will change CSS indentation to create nice visual
cascade of prefixes.
a {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box
}
You can disable this by specifying cascade: false in config/autoprefixer.yml
or in process() options.
Source Map
Autoprefixer will generate a source map if you set map option to true in
process method.
You must set input and output CSS files paths (by from and to options)
to generate a correct map.
result = AutoprefixerRails.process(css,
map: true,
from: 'main.css',
to: 'main.out.css')
Autoprefixer can also modify previous source map (for example, from Sass
compilation). Just set original source map content (as string) as prev
in the map option.
result = AutoprefixerRails.process(css, {
map: { prev: File.read('main.sass.css.map') },
from: 'main.sass.css',
to: 'main.min.css')
result.map #=> Source map from main.sass to main.min.css
See all options in PostCSS docs. AutoprefixerRails will convert Ruby style
to JS style, so you can use map: { sources_content: false }
instead of camelcase sourcesContent.
Security Contact
To report a security vulnerability, please use the Tidelift security contact.
Tidelift will coordinate the fix and disclosure.
ai/autoprefixer-rails có 1.2k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/ai/autoprefixer-rails. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
ai/autoprefixer-rails có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho ai/autoprefixer-rails. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
ai/autoprefixer-rails có trang demo không?
Dự án có trang chủ ở https://twitter.com/autoprefixer. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
ai/autoprefixer-rails còn đang phát triển không?
Commit gần nhất trên ai/autoprefixer-rails là 1.3 năm trước (theo timestamp GitHub). Repo có 109 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
ai/autoprefixer-rails dùng license gì?
ai/autoprefixer-rails phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
ai/autoprefixer-rails viết bằng ngôn ngữ gì?
ai/autoprefixer-rails chủ yếu viết bằng Ruby. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc thêm về ai/autoprefixer-rails ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/ai/autoprefixer-rails là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về autoprefixer-rails?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về autoprefixer-rails.