我不能让自动前缀工作。它被调用,但在我的 css 代码中没有结果。
这里有 Sinatra 应用程序的说明 - https://github.com/ai/autoprefixer-rails
应用程序.rb
class Application < Sinatra::Base
# Load path and gems/bundler
$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
require "bundler"
Bundler.require
register Sinatra::AssetPipeline
assets = Sprockets::Environment.new
AutoprefixerRails.install(assets)
### other
# Actual Rails Assets integration, everything else is Sprockets
if defined?(RailsAssets)
RailsAssets.load_paths.each do |path|
settings.sprockets.append_path(path)
end
end
end
我查看了 gem 源代码,发现了这样的例子:
@assets = Sprockets::Environment.new
@assets.append_path(@dir.join('app/app/assets/stylesheets'))
AutoprefixerRails.install(@assets, browsers: ['chrome 25'])
或者
@dir = Pathname(__FILE__).dirname
@css = @dir.join('app/app/assets/stylesheets/test.css').read
AutoprefixerRails.process(@css)