Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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: (
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);
};
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: (
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');
};
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');
};
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);
};
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);
};
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);
};