0.0.4 • Published 3 years ago

postcss-auto2remvw v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

postcss-auto2remvw

test Codecov Coverage

PostCSS plugin auto change px to rem & vw.

Intro

The rem layout is affected by the root font-size, if Android turns on the font-size enlargement mode, it will cause the whole layout to crash.

The viewport scale under Android is forced to 1, some Canvas drawing content is slightly blurred. Some Android devices have bug in changing scale, too many devices are difficult to locate the problem.

This plugin will increase the size of css。

.foo {
  height: 100px;
}
.foo {
  height: 0.133333rem;
  height: 13.333333vw;
}

Usage

Step 1: Install plugin:

npm install --save-dev postcss postcss-auto2remvw

Step 2: Check you project for existed PostCSS config: postcss.config.js in the project root, "postcss" section in package.json or postcss in bundle config.

If you do not use PostCSS, add it according to official docs and set this plugin in settings.

Step 3: Add the plugin to plugins list:

module.exports = {
  plugins: [
+   require('postcss-auto2remvw')(config),
    require('autoprefixer')
  ]
}

Config

NameTypeDefaultDescription
baseSize{ rem: number, vw: number }{ rem: 750, vw: 7.5 }Base unit of the design draft for comparison with px ( If you change this value you must have both rem and vw )
precisionint6Calculation accuracy
forceRemPropsstring[]["font", "font-size"]Force only rem units to be used for properties
keepRuleCommentstring"no-RemVw-next-line"Disable next line to use auto2remvw, must use like /* no-RemVw-next-line */
keepFileCommentstring"auto2remvw-disable"Disable whole file to use auto2remvw ( must be the first line of the file )
customConfigs{ test: RegExp, config: Config }[]undefinedSpecify part of the file to use other configurations

postcss official docs