@stylable/core
Version:
CSS for Components
20 lines (16 loc) • 614 B
text/typescript
import postcss from 'postcss';
import postcssNested from 'postcss-nested';
import { CSSObject } from './types';
const postcssJS = require('postcss-js');
const safeParser = require('postcss-safe-parser');
const postcssConfig = { parser: postcssJS };
const processor = postcss([postcssNested()]);
export function cssObjectToAst(cssObject: CSSObject, sourceFile = '') {
return processor.process(cssObject, { from: sourceFile, ...postcssConfig });
}
export function safeParse(
css: string,
options: postcss.ProcessOptions = { from: 'style.css' }
): postcss.Root {
return safeParser(css, options);
}