A JavaScript module to parse CSS Custom Properties from CSS files into a JavaScript Object.
/* input.css */
:root {
--example-custom-property: 2rem;
}
import parseCssCustomProperties, {
sync as parseCustomCssPropertiesSync,
} from '@saulhardman/parse-css-custom-properties';
(async () => {
const customProperties = await parseCssCustomProperties(['input.css']);
console.log(customProperties);
// { '--example-custom-property': '2rem' }
})();
const customProperties = parseCustomCssPropertiesSync(['input.css']);
console.log(customProperties);
// { '--example-custom-property': '2rem' }
Configure npm client:
# .npmrc
@saulhardman:registry=https://npm.pkg.github.com
# .yarnrc
"@saulhardman:registry" "https://npm.pkg.github.com"
Note: If you'd like this package to be available via the npm package registry as well as the GitHub Package Registry then please create an issue.
Using npm:
> npm install --save-dev @saulhardman/parse-css-custom-properties
Using Yarn:
> yarn add --dev @saulhardman/parse-css-custom-properties
Type: Array
Default: []
An array of glob
patterns that match the CSS files to parse.
Type: Object
Default: { globOptions: undefined }
Type: Object
Default: undefined
Options passed to glob
.
MIT © Saul Hardman