Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack2里应该怎么去配置remUnit这个参数? #16

Open
allroad88888888 opened this issue Aug 22, 2017 · 2 comments
Open

webpack2里应该怎么去配置remUnit这个参数? #16

allroad88888888 opened this issue Aug 22, 2017 · 2 comments

Comments

@allroad88888888
Copy link

用的postcss-loader,在postcss.config.js里面加入
module.exports = {
plugins: [
require('autoprefixer'),
require('postcss-px2rem')
]
}。
webpack配置
{
test: /.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{loader: "css-loader"},
{loader:"postcss-loader"}
]
})
}
怎么去配置remUnit这个参数呢

@whidy
Copy link

whidy commented Aug 24, 2017

你可以试试创建一个postcss.config.js,然后用

module.exports = {
  plugins: [
    require('postcss-px2rem')({
      remUnit: 75
    })
  ]
}

可以参考我的半成品示例postcss学习

或者不通过postcss直接单独用px2rem-loader,例如:

{
  test: /\.scss$/,
  use: ExtractTextPlugin.extract({
    fallback: "style-loader",
    use: [{
      loader: "css-loader"
    }, {
      loader: "px2rem-loader",
      options: {
        remUnit: 75
      }
    }, {
      loader: "sass-loader"
    }, ]
  })
}

可参考我最近也在看这块
px2rem插件示例

@136985627
Copy link

如果设计稿时640的时候 怎么去换算这个remUnit 的值呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants