create-react-app 版本3.2

react

create-react-app vw-layout

yarn eject  为了打开webpack.config.js

yarn start

假如报错了  yarn add @babel/plugin-syntax-jsx -D

第一步完成辣

yarn add postcss-aspect-ratio-mini postcss-px-to-viewport postcss-write-svg postcss-cssnext postcss-viewport-units cssnano -D

引入依赖

const postcssAspectRatioMini = require('postcss-aspect-ratio-mini');

const postcssPxToViewport = require('postcss-px-to-viewport');

const postcssWriteSvg = require('postcss-write-svg');

const postcssCssnext = require('postcss-cssnext');

const postcssViewportUnits = require('postcss-viewport-units');

const cssnano = require('cssnano');

复制这段到

 postcssAspectRatioMini({}),

            postcssPxToViewport({

              viewportWidth: 750, // (Number) The width of the viewport. 

              viewportHeight: 1334, // (Number) The height of the viewport. 

              unitPrecision: 3, // (Number) The decimal numbers to allow the REM units to grow to. 

              viewportUnit: 'vw', // (String) Expected units. 

              selectorBlackList: ['.ignore', '.hairlines'], // (Array) The selectors to ignore and leave as px. 

              minPixelValue: 1, // (Number) Set the minimum pixel value to replace. 

              mediaQuery: false // (Boolean) Allow px to be converted in media queries. 

            }),

            postcssWriteSvg({

              utf8: false

            }),

            postcssCssnext({}),

            postcssViewportUnits({}),

            cssnano({

              preset: "advanced",

              autoprefixer: false,

              "postcss-zindex": false

            }),

  感觉可以了,又报错了

yarn add cssnano-preset-advanced -D

yarn start 

运行成功!试试打包呗

有报错了

  "not dead",去掉这一句 

以上是 create-react-app 版本3.2 的全部内容, 来源链接: utcz.com/z/382362.html

回到顶部