How to use postcss-scss - 6 common examples

To help you get started, we’ve selected a few postcss-scss examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DomainGroupOSS / sass-to-emotion / transform.js View on Github external
root.walkAtRules('mixin', (atRule) => {
    const { params } = atRule;
    const selector = mixinParamsToFunc(params);

    let contents = '';
    postcssScss.stringify(atRule, (string, node, startOrEnd) => {
      // if node.type === decl skip when doing this above
      // stops first and last part entering the string e.g "@mixin ad-exact($width, $height) {"
      if (node && node === atRule && startOrEnd) return;

      contents += string;
    });

    let isUsedInFile = false;
    // search to see if mixin is used in file
    root.walkAtRules('include', (rule) => {
      if (rule.originalParams.split('(')[0] === params.split('(')[0]) {
        isUsedInFile = true;
      }
    });

    output.classes.set(selector, {
github DomainGroupOSS / sass-to-emotion / transform.js View on Github external
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
github DomainGroupOSS / sass-to-emotion / transform.js View on Github external
}

    if (
      checkUpTree(
        rule,
        nodeToCheck => nodeToCheck.type === 'atrule' && nodeToCheck.name === 'mixin',
      )
    ) return;

    if (rule.contentsAlreadyPrinted) {
      return;
    }

    let contents = '';

    postcssScss.stringify(rule, (string, node, startOrEnd) => {
      if (node && node === rule && startOrEnd) return;

      // asumption here is that there is some state involved
      // e.g &:hover or &.is-selected.
      const nestedInAmpersand = node
        && checkUpTree(
          node,
          nodeToCheck => nodeToCheck.type === 'rule' && nodeToCheck.selector.startsWith('&'),
        );

      if (node && isPlaceHolder) {
        node.contentsAlreadyPrinted = true;
      }

      // ref class if nested in ampersand
      if (
github springtype-org / springtype / src / packages / cli / st-tss / src / cli.ts View on Github external
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);
            }
github XhmikosR / find-unused-sass-variables / lib / parse-variable.js View on Github external
function parse(scssString, ignoreList) {
    const parsedScss = scssParse(scssString);
    const variables = [];

    parseNodes(parsedScss.nodes, variables, ignoreList);
    return variables;
}
github waka / gulp-sprockets / src / parsers / css.js View on Github external
parse(code) {
    this._ast = postcss.parse(code);
  }

postcss-scss

SCSS parser for PostCSS

MIT
Latest version published 1 year ago

Package Health Score

72 / 100
Full package analysis

Popular postcss-scss functions