Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = (cssString, filePath, pathToVariables = '../variables') => {
const root = postcssScss.parse(cssString, { from: filePath });
const output = processRoot(root, filePath);
// e.g styles.scss
const isJustSassImports = root.nodes.every(
node => node.type === 'atrule' && node.name === 'import',
);
if (isJustSassImports) return null;
let fileIsJustVarExports = true;
const classesEntries = Array.from(output.classes.entries());
const oneDefault = classesEntries.filter(([, { isUsedInFile }]) => !isUsedInFile).length === 1;
const emotionExports = classesEntries
const code = fs.readFileSync(file, 'utf8');
let destinationFile = destinationDirectory + path.sep + file.replace(sourceDirectory, '');
let tss = '';
console.log('Transforming', file, 'to', destinationFile);
switch (fileNameExtension(file)) {
case "sass":
console.error('TODO: Sass not implemented yet, file will be empty!');
postcssSass.process(code).result.root;
sassFiles++;
break;
case "scss":
console.error('TODO: Sass not implemented yet, file will be empty!');
postcssScss.parse(code);
scssFiles++;
break;
case "less":
console.error('TODO: Sass not implemented yet, file will be empty!');
postcssLess.parse(code);
lessFiles++;
break;
case "css":
tss = transformCSStoTSS(postcssCss.parse(code));
destinationFile = destinationFile.replace('.css', '.tss.ts');
cssFiles++;
}
if (!existsSync(destinationDirectory)) {
mkdirSync(destinationDirectory);
}
function parse(scssString, ignoreList) {
const parsedScss = scssParse(scssString);
const variables = [];
parseNodes(parsedScss.nodes, variables, ignoreList);
return variables;
}
parse(code) {
this._ast = postcss.parse(code);
}