{"name":"postcss-pxtorem","description":"A CSS post-processor that converts px to rem.","version":"6.0.0","author":{"name":"cuth"},"license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/cuth/postcss-pxtorem.git"},"bugs":{"url":"https://github.com/cuth/postcss-pxtorem/issues"},"main":"index.js","scripts":{"lint":"eslint .","test":"jasmine-node spec"},"husky":{"hooks":{"pre-commit":"lint-staged"}},"lint-staged":{"*.js":["eslint --fix","prettier --write"]},"devDependencies":{"eslint":"^6.8.0","husky":"^4.2.3","jasmine-node":"^3.0.0","lint-staged":"^10.0.8","postcss":"^8.0.0","prettier":"^1.19.1"},"keywords":["css","rem","pixel","px","postcss","postcss-plugin"],"peerDependencies":{"postcss":"^8.0.0"},"gitHead":"122649015322214f8e9d1ac852eb11c0791b634b","homepage":"https://github.com/cuth/postcss-pxtorem#readme","_id":"postcss-pxtorem@6.0.0","_nodeVersion":"12.18.0","_npmVersion":"7.6.0","dist":{"integrity":"sha512-ZRXrD7MLLjLk2RNGV6UA4f5Y7gy+a/j1EqjAfp9NdcNYVjUMvg5HTYduTjSkKBkRkfqbg/iKrjMO70V4g1LZeg==","shasum":"f228a4d05d8a73f0642eabae950e2b19836366d7","tarball":"http://registry-npm.ywwl.com/postcss-pxtorem/download/postcss-pxtorem-6.0.0.tgz","fileCount":12,"unpackedSize":30040,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgQvUfCRA9TVsSAnZWagAAMAcP/A9JcflpnQfFcsnaFuv2\nAa0Hxi3OFy4BRaidqvFC37H40EKUv3YVJVub6Uo07PQA7MKyDFt93mhvYIM9\njMG99NNdC4BNjRRQ3H9d0ezpWHWshhMu2uDPBr9m/6WZ4kujSUfLYnxcDgy2\nyXdIE/YVd/Rs26gl4IojQ/jM8zHDUj/zPRdDoZ1o887zlxp4+vpNKZeXHTl2\nWM9gr+f3CYfA6PIS5MeeBhST+uXWtFIuo88D0AkMCxIswm9zZSDBDQ+G8inm\neGQ6iH2c2VGr1Ikkil3wq7KGEXtQNuMeFofj6piFjRjPfNKtxNPiz25CoUdA\naow3+XePdKsHIUnum9MMZ8ZYxEIix+Q2KwhAyJatiCpUml0tegPgdGIYjGRW\n2Z1fWj1oGsvp+cM2VqlVczrNSlIp0E6/uTXaRQVE+B6OpwZ6nLh3TjWrmGcL\n/DI9EXloa0/mlmzOCLaUnBjFChpv9Scy0jwJ418Yr2y20M7SdvN+h7/NsRCt\niBhmsj4o9kIBzpGlLEgxmnPIWmEu6hZ4ia3V3LIltu3L2Kg+SA4mskvKq9lP\nv3xLPm2mJJ5QKrN1nmb9fMdBaVK1TYE15i/POuUU+jcbs3JojuV4AqlEpTXT\nul5dHxTAi3L12DoBVQZ+nMuLikB/rV7U6yNPKg1u7btP3rgnMcSDo3jb6dBo\nowFD\r\n=rf2q\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHPpxSmWFFCmAQHe58Vlc+QwNmKMYuOv8uorJj0AWkO6AiEAlUnNddagJ9/LrD8stwqsropXu1tX6/+lJMAtvaL1kXc="}],"size":7376,"noattachment":false,"key":"/postcss-pxtorem/-/postcss-pxtorem-6.0.0.tgz"},"_npmUser":{"name":"cuth","email":"jon@cuth.net"},"directories":{},"maintainers":[{"name":"cuth","email":"jon@cuth.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/postcss-pxtorem_6.0.0_1615000863414_0.413472929273893"},"_hasShrinkwrap":false,"readme":"# postcss-pxtorem [![NPM version](https://badge.fury.io/js/postcss-pxtorem.svg)](http://badge.fury.io/js/postcss-pxtorem)\n\nA plugin for [PostCSS](https://github.com/ai/postcss) that generates rem units from pixel units.\n\n## Install\n\n```shell\n$ npm install postcss postcss-pxtorem --save-dev\n```\n\n## Usage\n\nPixels are the easiest unit to use (*opinion*). The only issue with them is that they don't let browsers change the default font size of 16. This script converts every px value to a rem from the properties you choose to allow the browser to set the font size.\n\n\n### Input/Output\n\n*With the default settings, only font related properties are targeted.*\n\n```css\n// input\nh1 {\n    margin: 0 0 20px;\n    font-size: 32px;\n    line-height: 1.2;\n    letter-spacing: 1px;\n}\n\n// output\nh1 {\n    margin: 0 0 20px;\n    font-size: 2rem;\n    line-height: 1.2;\n    letter-spacing: 0.0625rem;\n}\n```\n\n### Example\n\n```js\nvar fs = require('fs');\nvar postcss = require('postcss');\nvar pxtorem = require('postcss-pxtorem');\nvar css = fs.readFileSync('main.css', 'utf8');\nvar options = {\n    replace: false\n};\nvar processedCss = postcss(pxtorem(options)).process(css).css;\n\nfs.writeFile('main-rem.css', processedCss, function (err) {\n  if (err) {\n    throw err;\n  }\n  console.log('Rem file written.');\n});\n```\n\n### options\n\nType: `Object | Null`  \nDefault:\n```js\n{\n    rootValue: 16,\n    unitPrecision: 5,\n    propList: ['font', 'font-size', 'line-height', 'letter-spacing'],\n    selectorBlackList: [],\n    replace: true,\n    mediaQuery: false,\n    minPixelValue: 0,\n    exclude: /node_modules/i\n}\n```\n\n- `rootValue` (Number | Function) Represents the root element font size or returns the root element font size based on the [`input`](https://api.postcss.org/Input.html) parameter\n- `unitPrecision` (Number) The decimal numbers to allow the REM units to grow to.\n- `propList` (Array) The properties that can change from px to rem.\n    - Values need to be exact matches.\n    - Use wildcard `*` to enable all properties. Example: `['*']`\n    - Use `*` at the start or end of a word. (`['*position*']` will match `background-position-y`)\n    - Use `!` to not match a property. Example: `['*', '!letter-spacing']`\n    - Combine the \"not\" prefix with the other prefixes. Example: `['*', '!font*']`\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- `replace` (Boolean) Replaces rules containing rems instead of adding fallbacks.\n- `mediaQuery` (Boolean) Allow px to be converted in media queries.\n- `minPixelValue` (Number) Set the minimum pixel value to replace.\n- `exclude` (String, Regexp, Function) The file path to ignore and leave as px.\n    - If value is string, it checks to see if file path contains the string.\n        - `'exclude'` will match `\\project\\postcss-pxtorem\\exclude\\path`\n    - If value is regexp, it checks to see if file path matches the regexp.\n        - `/exclude/i` will match `\\project\\postcss-pxtorem\\exclude\\path`\n    - If value is function, you can use exclude function to return a true and the file will be ignored.\n        - the callback will pass the file path as  a parameter, it should returns a Boolean result.\n        - `function (file) { return file.indexOf('exclude') !== -1; }`\n- `unit` (String) Set the default unit to convert, default is `px`.\n\n### Use with gulp-postcss and autoprefixer\n\n```js\nvar gulp = require('gulp');\nvar postcss = require('gulp-postcss');\nvar autoprefixer = require('autoprefixer');\nvar pxtorem = require('postcss-pxtorem');\n\ngulp.task('css', function () {\n\n    var processors = [\n        autoprefixer({\n            browsers: 'last 1 version'\n        }),\n        pxtorem({\n            replace: false\n        })\n    ];\n\n    return gulp.src(['build/css/**/*.css'])\n        .pipe(postcss(processors))\n        .pipe(gulp.dest('build/css'));\n});\n```\n\n### A message about ignoring properties\nCurrently, the easiest way to have a single property ignored is to use a capital in the pixel unit declaration.\n\n```css\n// `px` is converted to `rem`\n.convert {\n    font-size: 16px; // converted to 1rem\n}\n\n// `Px` or `PX` is ignored by `postcss-pxtorem` but still accepted by browsers\n.ignore {\n    border: 1Px solid; // ignored\n    border-width: 2PX; // ignored\n}\n```\n","publish_time":1615000863587,"_cnpm_publish_time":1615000863587,"dist-tags":{"latest":"6.1.0"}}