How to use the csso.compress function in csso

To help you get started, we’ve selected a few csso 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 basisjs / basisjs-tools / lib / build / css / pack.js View on Github external
flow.css.packages.forEach(function(file){
    fconsole.log(file.relOutputFilename);
    // make a copy of ast, as it could has shared parts
    // and csso optimizer might corrupt those parts
    file.ast = csso.compress(copyAst(file.ast));
  });
  fconsole.endl();
github basisjs / basisjs-tools / lib / build / css / pack.js View on Github external
fconsole.start('Process packages');
  flow.css.packages.forEach(function(file){
    fconsole.log(file.relOutputFilename);
    // make a copy of ast, as it could has shared parts
    // and csso optimizer might corrupt those parts
    file.ast = csso.compress(copyAst(file.ast));
  });
  fconsole.endl();

  fconsole.start('Process style attributes');
  for (var i = 0, file; file = flow.files.queue[i]; i++)
    if (file.type == 'style-block')
    {
      fconsole.log(file.relpath);
      file.ast = csso.compress(
        [{}, 'stylesheet', [{}, 'ruleset', [{}, 'selector', [{}, 'simpleselector', [{}, 'ident', 'rule']]],
          file.ast
        ]])[2][3];
    }
  fconsole.end();
}).handlerName = '[css] Compress';
github revskill10 / next-template / modules / core / lib / hocs / with-document.js View on Github external
page = renderPage((App) => (props) => {
          pageContext = props.pageContext
          return sheet.collectStyles()
        }
      );
      } else {
        page = renderPage((App) => (props) =>
          sheet.collectStyles(),
        );
      }
      
      const styleTags = sheet.getStyleElement()
      if (!phone) {
        const css = pageContext.sheetsRegistry.toString()
        const ast = csso.syntax.parse(css);
        const compressedAst = csso.compress(ast).ast;
        const minifiedCss = csso.syntax.generate(compressedAst);
        return { 
          ...page, 
          phone,
          pageContext,
          styleTags,
          styles: (
github devinit / datahub / packages / app / src / scripts / critical-css.ts View on Github external
const main = async (siteUrl: string, filePath) => {
    const css = await getCss(siteUrl);
    const ast = csso.syntax.parse(css[0].css);
    const compressedAst = csso.compress(ast, {comments: false}).ast;
    const minifiedCss = csso.syntax.generate(compressedAst);
    const content = cssModule(minifiedCss);
    await fs.writeFile(filePath,  prettier.format(content, { singleQuote: true }));
    console.log('success');
};
github montagejs / mop / lib / transform / css.js View on Github external
config.out.warn("Unknown URI type:", value);
                continue;
            }

            value[1] = quote+rebase(uri, file, config)+quote;
        }

        for (var i = node.length - 1; i >= 0; i--) {
            if (Array.isArray(node[i])) {
                worklist.push(node[i]);
            }
        }
    }

    try {
        ast = CSSO.compress(ast);
    } catch (error) {
        config.out.warn("CSS compression error: " + file.path);
        config.out.warn(error.message);
    }

    try {
        ast = CSSO.cleanInfo(ast);
    } catch (error) {
        config.out.warn("CSS clean info error: " + file.path);
        config.out.warn(error.message);
    }

    return CSSO.translate(ast);
}
github devinit / datahub / src / scripts / vendor.ts View on Github external
const compressCSS = async (file: string): Promise => {
  const content = await fs.readFile(file, { encoding: 'utf8' });
  const ast = csso.syntax.parse(content);
  const compressedAst = csso.compress(ast, { comments: false }).ast;

  return csso.syntax.generate(compressedAst);
};
github montagejs / mop / lib / transform / css.js View on Github external
config.out.warn("Unknown URI type:", value);
                    continue;
                }
                if (uri.indexOf(":") === -1) {
                    value[1] = quote + URL.resolve(base, uri) + quote;
                }
            }
            for (i = node.length - 1; i >= 0; i--) {
                if (Array.isArray(node[i])) {
                    worklist.push(node[i]);
                }
            }
        }
    }
    try {
        ast = CSSO.compress(ast);
    } catch (error) {
        config.out.warn("CSS compression error: ");
        config.out.warn(error.message);
    }
    try {
        ast = CSSO.cleanInfo(ast);
    } catch (error) {
        config.out.warn("CSS clean info error:");
        config.out.warn(error.message);
    }
    return CSSO.translate(ast);
}
github devinit / datahub / packages / app / src / scripts / vendor.ts View on Github external
const compressCSS = async (file: string): Promise => {
  const content = await fs.readFile(file, {encoding: 'utf8'});
  const ast = csso.syntax.parse(content);
  const compressedAst = csso.compress(ast, {comments: false}).ast;
  return csso.syntax.generate(compressedAst);
};

csso

CSS minifier with structural optimisations

MIT
Latest version published 2 years ago

Package Health Score

76 / 100
Full package analysis