How to use the csso.syntax 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 revskill10 / next-template / modules / core / lib / hocs / with-document.js View on Github external
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 peterbe / minimalcss / src / run.js View on Github external
enter: (_node, item, list) => {
      comments.append(list.remove(item));
    }
  });
  allCombinedAst.children.prependList(comments);

  // Why not just allow the return of the "unminified" CSS (in case
  // some odd ball wants it)?
  // 'allCombinedAst' concatenates multiple payloads of CSS.
  // It only contains the selectors that are supposedly
  // in the DOM. However it does contain *duplicate* selectors.
  // E.g. `p { color: blue; } p { font-weight: bold; }`
  // When ultimately, what was need is `p { color: blue; font-weight: bold}`.
  // The csso.minify() function will solve this, *and* whitespace minify
  // it too.
  csso.syntax.compress(allCombinedAst, cssoOptions);
  postProcessOptimize(allCombinedAst);
  const finalCss = csstree.generate(allCombinedAst);
  const returned = {
    finalCss,
    stylesheetContents
  };
  return Promise.resolve(returned);
};
github revskill10 / next-template / modules / core / lib / hocs / with-document.js View on Github external
if (!phone) {
        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 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 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 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);
};
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);
};

csso

CSS minifier with structural optimisations

MIT
Latest version published 2 years ago

Package Health Score

76 / 100
Full package analysis