{"_id":"postcss-px-to-viewport-opt","_rev":"879987","name":"postcss-px-to-viewport-opt","description":"A CSS post-processor that converts px to viewport units (vw, vh, vmin, vmax).","dist-tags":{"latest":"0.0.4"},"maintainers":[{"name":"linph","email":"370345882@qq.com"}],"time":{"modified":"2024-07-17T18:04:55.000Z","created":"2018-05-16T03:46:56.043Z","0.0.4":"2018-05-16T03:46:56.043Z"},"users":{},"author":{"name":"linph","email":"370345882@qq.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/linpenghui958/postcss-px-to-viewport.git"},"versions":{"0.0.4":{"name":"postcss-px-to-viewport-opt","description":"A CSS post-processor that converts px to viewport units (vw, vh, vmin, vmax).","version":"0.0.4","author":{"name":"linph","email":"370345882@qq.com"},"license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/linpenghui958/postcss-px-to-viewport.git"},"bugs":{"url":"https://github.com/linpenghui958/postcss-px-to-viewport/issues"},"homepage":"https://github.com/linpenghui958/postcss-px-to-viewport","main":"index.js","keywords":["css","units","pixel","px","viewport","vw","vh","vmin","vmax","postcss","postcss-plugin"],"dependencies":{"object-assign":"^4.0.1","postcss":"^5.0.2"},"_from":"postcss-px-to-viewport@0.0.3","_resolved":"http://registry.npm.taobao.org/postcss-px-to-viewport/download/postcss-px-to-viewport-0.0.3.tgz","gitHead":"472a745df3316d2a591f640f8df0f42f63e0ee8f","_id":"postcss-px-to-viewport-opt@0.0.4","_npmVersion":"5.4.2","_nodeVersion":"8.7.0","_npmUser":{"name":"linph","email":"370345882@qq.com"},"dist":{"integrity":"sha512-pn8fOrZ/qgiP7fNiYxoIL/iZhijy8f9pm+YUXvUTABY0H1mC5WzH7n1BkfCmRHANzSdZj2ipLOrwgomro3RNcA==","shasum":"c988c24c8ba8e40b14277efdfa96bb862b0e0430","tarball":"http://registry-npm.ywwl.com/postcss-px-to-viewport-opt/download/postcss-px-to-viewport-opt-0.0.4.tgz","fileCount":7,"unpackedSize":9071,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa+6mwCRA9TVsSAnZWagAAPKAP/1rLwgL6ioNT72fM/IFC\nZAkcREjdjTg5lmd8bp9r3XbIdHFFtsarAjTNJ9kZDmELvquZh+MhTeqCea1K\nirqiYfQ/xddzJIUKHqPaY4P4bBttd3P3EiN5FxJv0c1HHpEhok5bDX5is/C3\n5NfjzsoUePPMPYL/NddZqFC8XyJkkiA66dqQkVbh95esgI0lWTgu2WrHg5uc\niBzRCLutHwK/GMH3sHpuy90cMyV+SYC9fb9tIzAFkkhsJdQNBC0A0h9TrNF/\nwwBGdyRJU74kpw+8KNYb3EAsvD5IpiBtLgGrnMUdTODNwaFBW65Ypb6gP7Qz\nvE/4pSsP/16tlsybLd/AH9DG/82NhOFuR6JX7a8ADt/pa9Uka3QoZSaSFgKM\nNNpt+dALUH+MSzfZGR9G3qx1jCtp+/8eE1CmjACk8BT7uuN5XlNWYVF9wzfE\njcuxShTABpuqQS3NzY2jNrdw3BvGPqetiMjsWhrBiOHH440CW1zqLFCuNC+5\nieYY4KQ1RLlNl0R+YLAU/8FRGLSIiha2mcI2gyvcJqQtjRGrdN4eObhOUuoH\npAdDUiOUXaGZqgikKE7HlHoK0akZfxzXMv6oHJKtMK/yP0eiTMbFC6sTv4hq\nTgpCE5U9qsAgsmJvbsO07xAe75tb3F/w0nt8xqwbBwjjjkmTGZoeY0cjZt8D\ng1DW\r\n=cLEi\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCXtobBqLBfwmHORYsg0Q2+ogY2ISvsZeNbmxM2rFUwUQIgBm/enqvvGqZHf30mUT67fro9KxkNAPqPqTwjp8nPH+Y="}],"size":3675,"noattachment":false,"key":"/postcss-px-to-viewport-opt/-/postcss-px-to-viewport-opt-0.0.4.tgz"},"maintainers":[{"name":"linph","email":"370345882@qq.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/postcss-px-to-viewport-opt_0.0.4_1526442415982_0.9912731509205641"},"_hasShrinkwrap":false,"publish_time":1526442416043,"_cnpm_publish_time":1526442416043}},"readme":"#### 改造postcss-px-to-viewport\n\n##### 增加exclude配置项\n配置文件.postcssrc.js（修改第三方库被影响的情况）\n```\n\"postcss-px-to-viewport\": {\n      viewportWidth: 750,\n      viewportHeight: 1334,\n      unitPrecision: 3,\n      viewportUnit: 'vw',\n      selectorBlackList: ['.ignore', '.hairlines'],\n      minPixelValue: 1,\n      mediaQuery: false,\n      exclude: /(\\/|\\\\)(node_modules)(\\/|\\\\)/\n    },\n```\n\n# postcss-px-to-viewport [![NPM version](https://badge.fury.io/js/postcss-px-to-viewport.svg)](http://badge.fury.io/js/postcss-px-to-viewport)\n\nA plugin for [PostCSS](https://github.com/ai/postcss) that generates viewport units (vw, vh, vmin, vmax) from pixel units.\n\n## Usage\n\nIf your project involves a fixed width, this script will help to convert pixels into viewport units.\n\n### Input/Output\n\n```css\n// input\n\n.class {\n  margin: -10px .5vh;\n  padding: 5vmin 9.5px 1px;\n  border: 3px solid black;\n  border-bottom-width: 1px;\n  font-size: 14px;\n  line-height: 20px;\n}\n\n.class2 {\n  border: 1px solid black;\n  margin-bottom: 1px;\n  font-size: 20px;\n  line-height: 30px;\n}\n\n@media (min-width: 750px) {\n  .class3 {\n    font-size: 16px;\n    line-height: 22px;\n  }\n}\n\n// output\n\n.class {\n  margin: -3.125vw .5vh;\n  padding: 5vmin 2.96875vw 1px;\n  border: 0.9375vw solid black;\n  border-bottom-width: 1px;\n  font-size: 4.375vw;\n  line-height: 6.25vw;\n}\n\n.class2 {\n  border: 1px solid black;\n  margin-bottom: 1px;\n  font-size: 6.25vw;\n  line-height: 9.375vw;\n}\n\n@media (min-width: 234.375vw) {\n  .class3 {\n    font-size: 5vw;\n    line-height: 6.875vw;\n  }\n}\n```\n\n### Example\n\n```js\n'use strict';\n\nvar fs = require('fs');\nvar postcss = require('postcss');\nvar pxToViewport = require('..');\nvar css = fs.readFileSync('main.css', 'utf8');\nvar options = {\n    replace: false\n};\nvar processedCss = postcss(pxToViewport(options)).process(css).css;\n\nfs.writeFile('main-viewport.css', processedCss, function (err) {\n  if (err) {\n    throw err;\n  }\n  console.log('File with viewport units written.');\n});\n```\n\n### Options\n\nDefault:\n```js\n{\n  viewportWidth: 320,\n  viewportHeight: 568,\n  unitPrecision: 5,\n  viewportUnit: 'vw',\n  selectorBlackList: [],\n  minPixelValue: 1,\n  mediaQuery: false\n}\n```\n- `viewportWidth` (Number) The width of the viewport.\n- `viewportHeight` (Number) The height of the viewport.\n- `unitPrecision` (Number) The decimal numbers to allow the REM units to grow to.\n- `viewportUnit` (String) Expected units.\n- `selectorBlackList` (Array) The selectors to ignore and leave as px.\n    - If value is string, it checks to see if selector contains the string.\n        - `['body']` will match `.body-class`\n    - If value is regexp, it checks to see if the selector matches the regexp.\n        - `[/^body$/]` will match `body` but not `.body`\n- `minPixelValue` (Number) Set the minimum pixel value to replace.\n- `mediaQuery` (Boolean) Allow px to be converted in media queries.\n\n\n### Use with gulp-postcss\n\n```js\nvar gulp = require('gulp');\nvar postcss = require('gulp-postcss');\nvar pxtoviewport = require('postcss-px-to-viewport');\n\ngulp.task('css', function () {\n\n    var processors = [\n        pxtoviewport({\n            viewportWidth: 320,\n            viewportUnit: 'vmin'\n        })\n    ];\n\n    return gulp.src(['build/css/**/*.css'])\n        .pipe(postcss(processors))\n        .pipe(gulp.dest('build/css'));\n});\n```\n","_attachments":{},"homepage":"https://github.com/linpenghui958/postcss-px-to-viewport","bugs":{"url":"https://github.com/linpenghui958/postcss-px-to-viewport/issues"},"license":"MIT"}