Ver*_*y00 5 ruby-on-rails autoprefixer postcss webpacker ruby-on-rails-6
我正在使用 Webpacker 编写 Rails 6 webapp。我的理解是 Rails 6 中的自动前缀通过 PostCSS 和它的 autoprefixer 插件开箱即用。
但是我无法验证这个库是否实际上是我的 css 的前缀。
有没有办法确认标准默认 Rails 6.0.0 应用程序是否开箱即用自动前缀?
我已经跑去yarn autoprefixer --info看了它适用的 css 规则和浏览器,以及它适用于我的浏览器的 def chrome 77。我尝试使用它列出为适用的参数。然而,它仍然没有在开发或生产中显示任何带前缀的 css。
我不确定它是如何postcss-preset-env工作的,所以我不确定在使用需要前缀的浏览器时 css 是否只有前缀。
我来自使用 autoprefixer-rails gem,它挂在链轮上,只是给所有东西加上前缀。
这是我的.postcss.config.js文件...
module.exports = {
plugins: [
require('postcss-import'),
require('postcss-flexbugs-fixes'),
require('postcss-preset-env')({
autoprefixer: {
flexbox: 'no-2009'
},
stage: 3
})
]
}
Run Code Online (Sandbox Code Playgroud)
您可以通过运行来测试编译后的 CSS(包括 PostCSS 的输出)在生产中的样子
$ RAILS_ENV=production bundle exec rails webpacker:compile
Run Code Online (Sandbox Code Playgroud)