zl程序教程

您现在的位置是:首页 >  其他

当前栏目

react脚手架配置px自动转rem

2023-02-25 18:27:39 时间

配置方法

一、加两个依赖

1yarn add postcss-plugin-px2rem lib-flexible

二、config/webpack.config.js 文件下152行加入代码

1 [
2                    "postcss-plugin-px2rem",
3                    {
4                      rootValue: 60,
5                      unitPrecision: 5,
6                      propWhiteList: [],
7                      propBlackList: [],
8                      exclude: ["/node_modules/"],
9                      selectorBlackList: ["noRem"],
10                      ignoreIdentifier: false,
11                      replace: true,
12                      mediaQuery: false,
13                      minPixelValue: 10,
14                    },
15  ],

三、入口文件src/index.tsx引入lib-flexible

1import App from "./App";
2import "lib-flexible";