UNPKG

@thelabnyc/typed-scss-modules

Version:

TypeScript type definition generator for SCSS CSS Modules

17 lines (16 loc) 476 B
import postcss from "postcss"; import PostcssModulesPlugin from "postcss-modules"; /** * Converts a CSS source string to a list of exports (class names, keyframes, etc.) */ export const sourceToClassNames = async (source, file) => { let result = {}; await postcss([ PostcssModulesPlugin({ getJSON: (_, json) => { result = json; }, }), ]).process(source, { from: file }); return Object.keys(result); };