{"name":"css-node-extract","description":"Extract certain nodes from CSS code","keywords":["CSS"],"version":"2.1.0","author":{"name":"Markus Oberlehner"},"homepage":"https://github.com/maoberlehner/css-node-extract","license":"MIT","repository":{"type":"git","url":"git+https://github.com/maoberlehner/css-node-extract.git"},"bugs":{"url":"https://github.com/maoberlehner/css-node-extract/issues"},"dependencies":{"change-case":"^3.0.1","postcss":"^6.0.11"},"devDependencies":{"chai":"^4.1.2","mocha":"^3.5.3","postcss-less":"^1.1.0","postcss-scss":"^1.0.2","rimraf":"^2.6.2","tslint":"^5.7.0","typescript":"^2.5.2"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"npm run clean && tsc","watch":"npm run clean && tsc -w","clean":"rimraf dist","lint":"tslint src/**/*.ts","test:lib":"mocha test/lib/*.test.js","test:index":"mocha test/index.test.js","test":"mocha test/*"},"gitHead":"f1217d56c0842582a8b82fcd3e2efb3244f64b11","_id":"css-node-extract@2.1.0","_npmVersion":"5.4.2","_nodeVersion":"8.4.0","_npmUser":{"name":"maoberlehner","email":"markus.oberlehner@gmail.com"},"dist":{"integrity":"sha512-ubkHwak9PbsfNi6hewcq4yfI96rgcXt4KO+ojrJu46a5DAmMcLmr+n2lsEJ+h2cJxZWJtf4Z7t1M5s6MIkfRlQ==","shasum":"4f9902cc5b227060ecbef27d07783afcfd1c4c9b","tarball":"http://registry-npm.ywwl.com/css-node-extract/download/css-node-extract-2.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDjGYjYLzd2VcQwkUTzP8/ypqQoS+URTax+KBe6DGS/mwIgT79WRnadcGeGXhDlPh22NkmkcIz8u0jUA8/lcQPacxw="}],"size":7380,"noattachment":false,"key":"/css-node-extract/-/css-node-extract-2.1.0.tgz"},"maintainers":[{"name":"maoberlehner","email":"markus.oberlehner@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/css-node-extract-2.1.0.tgz_1505655994330_0.20435941242612898"},"directories":{},"readme":"# css-node-extract\n\n[![Patreon](https://img.shields.io/badge/patreon-donate-blue.svg)](https://www.patreon.com/maoberlehner)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://paypal.me/maoberlehner)\n[![Build Status](https://travis-ci.org/maoberlehner/css-node-extract.svg?branch=master)](https://travis-ci.org/maoberlehner/css-node-extract)\n[![Coverage Status](https://coveralls.io/repos/github/maoberlehner/css-node-extract/badge.svg?branch=master)](https://coveralls.io/github/maoberlehner/css-node-extract?branch=master)\n[![GitHub stars](https://img.shields.io/github/stars/maoberlehner/css-node-extract.svg?style=social&label=Star)](https://github.com/maoberlehner/css-node-extract)\n\nExtract certain nodes from CSS code.\n\n## Filters\n\n- **at-rules**: `@media`, `@supports`, `@mixin`,...\n- **declarations**: `$variable`, `@variable`,...\n- **functions**: `@function`\n- **mixins**: `@mixin` and `.less-mixin-selector()`\n- **rules**: `.class-selector`, `#id-selector`,...\n- **silent**: Extract only nodes that do not compile to CSS code (mixins, placeholder selectors, variables,...)\n- **variables**: `$sass-variable` and `@less-variable`\n- **make-your-own**: Define custom filters\n\n## Demos\n\n```js\nconst cssNodeExtract = require('css-node-extract');\nconst postcssScssSyntax = require('postcss-scss');\n\nconst options = {\n  // CSS source code as string.\n  css: '$variable: \"value\"; .selector { } .other-selector { }',\n  // Extract only variables.\n  filters: ['variables'],\n  // postcss syntax plugin to add support for SCSS code.\n  postcssSyntax: postcssScssSyntax\n};\n\n// Asynchronous:\ncssNodeExtract.process(options).then((extractedCss) => {\n  console.log(extractedCss); // Outputs: '$variable: \"value\";'.\n});\n\n// Synchronous:\nconst extractedCss = cssNodeExtract.processSync(options);\nconsole.log(extractedCss); // Outputs: '$variable: \"value\";'.\n```\n\n### Custom filter\n\n```js\nconst cssNodeExtract = require('css-node-extract');\n\nconst options = {\n  // CSS source code as string.\n  css: '@keyframes { } .selector { } .other-selector { }',\n  filters: ['my-keyframe-filter'],\n  customFilters: {\n    myKeyframeFilter: [\n      [\n        { property: 'type', value: 'atrule' },\n        { property: 'name', value: 'keyframes' }\n      ]\n    ]\n  }\n};\n\ncssNodeExtract.process(options).then((extractedCss) => {\n  console.log(extractedCss); // Outputs: '@keyframes { }'.\n});\n```\n\n### Preserve lines\n\nUsually `css-node-extract` removes all nodes which do not match the given filters. However under some circumstances it might be useful to preserve the original line numbers (e.g. to keep source map references intact).\n\n```js\nconst cssNodeExtract = require('css-node-extract');\n\nconst options = {\n  css: '$variable: \"value\"; .selector { } .other-selector { }',\n  filters: ['variables'],\n  postcssSyntax: postcssScssSyntax,\n  preserveLines: true\n};\n\ncssNodeExtract.process(options).then((extractedCss) => {\n  // Outputs the extracted nodes with empty lines where\n  // other nodes got removed to preserve line numbers.\n  console.log(extractedCss);\n});\n```\n\n### ES2015 named exports\n\n```js\nimport { process, processSync } from 'css-node-extract';\nimport postcssScssSyntax from 'postcss-scss';\n\nconst options = {\n  // CSS source code as string.\n  css: '$variable: \"value\"; .selector { } .other-selector { }',\n  // Extract only variables.\n  filters: ['variables'],\n  // postcss syntax plugin to add support for SCSS code.\n  postcssSyntax: postcssScssSyntax\n};\n\n// Asynchronous:\nprocess(options).then((extractedCss) => {\n  console.log(extractedCss); // Outputs: '$variable: \"value\";'.\n});\n\n// Synchronous:\nprocessSync(options);\nconsole.log(extractedCss); // Outputs: '$variable: \"value\";'.\n```\n\n## Upgrade from 1.x.x to 2.x.x\n\nWith version 2.0.0 the handling of custom filters was changed. The `customFilter` option was renamed to `customFilters` and this option now takes an object instead of an array. Instead of defining one custom filter named `custom`, you can now define unlimited custom filters with custom names.\n\n## Upgrade from 0.x.x to 1.x.x\n\nWith version 1.0.0 the `filterNames` option was renamed to `filters`.\n\n```js\n// New\nconst options = {\n  css: '$variable: \"value\"; .selector { } .other-selector { }',\n  filters: ['variables'],\n  postcssSyntax: postcssScssSyntax\n};\n\n// Old\nconst options = {\n  css: '$variable: \"value\"; .selector { } .other-selector { }',\n  filterNames: ['variables'],\n  postcssSyntax: postcssScssSyntax\n};\n```\n\n## Development\n\nSee [CONTRIBUTING.md](https://github.com/maoberlehner/css-node-extract/blob/master/CONTRIBUTING.md)\n\n### Testing\n\n```bash\nnpm test\n```\n\n## About\n\n### Author\n\nMarkus Oberlehner  \nWebsite: https://markus.oberlehner.net  \nTwitter: https://twitter.com/MaOberlehner  \nPayPal.me: https://paypal.me/maoberlehner  \nPatreon: https://www.patreon.com/maoberlehner\n\n### License\n\nMIT\n","publish_time":1505655995285,"_cnpm_publish_time":1505655995285,"dist-tags":{"latest":"3.0.4"}}