Socket
Socket
Sign inDemoInstall

postcss-critical-css

Package Overview
Dependencies
93
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.5 to 3.0.0

23

lib/index.js

@@ -30,2 +30,7 @@ 'use strict';

/**
* Append to an existing critical CSS file?
*/
var append = false;
/**
* Clean the original root node passed to the plugin, removing custom atrules,

@@ -40,6 +45,14 @@ * properties. Will additionally delete nodes as appropriate if

root.walkAtRules('critical', function (atRule) {
if (preserve === false && !atRule.nodes) {
root.removeAll();
if (preserve === false) {
if (atRule.nodes && atRule.nodes.length) {
atRule.remove();
} else {
root.removeAll();
}
} else {
atRule.remove();
if (atRule.nodes && atRule.nodes.length) {
atRule.replaceWith(atRule.nodes);
} else {
atRule.remove();
}
}

@@ -126,3 +139,4 @@ });

function writeCriticalFile(filePath, css) {
_fs2.default.writeFile(filePath, css, function (err) {
_fs2.default.writeFile(filePath, css, { flag: append ? 'a' : 'w' }, function (err) {
append = true;
if (err) {

@@ -154,2 +168,3 @@ console.error(err);

}, filteredOptions);
append = false;
return function (css) {

@@ -156,0 +171,0 @@ var dryRun = args.dryRun,

4

package.json
{
"name": "postcss-critical-css",
"version": "2.1.5",
"version": "3.0.0",
"description": "Generate critical CSS using PostCSS",

@@ -34,3 +34,3 @@ "main": "index.js",

"eslint-plugin-standard": "^3.0.1",
"flow-bin": "^0.45.0",
"flow-bin": "^0.48.0",
"minimist": "^1.2.0",

@@ -37,0 +37,0 @@ "tape": "^4.6.0"

@@ -11,2 +11,7 @@ // @flow

/**
* Append to an existing critical CSS file?
*/
let append = false
/**
* Clean the original root node passed to the plugin, removing custom atrules,

@@ -21,6 +26,14 @@ * properties. Will additionally delete nodes as appropriate if

root.walkAtRules('critical', (atRule: Object) => {
if (preserve === false && !atRule.nodes) {
root.removeAll()
if (preserve === false) {
if (atRule.nodes && atRule.nodes.length) {
atRule.remove()
} else {
root.removeAll()
}
} else {
atRule.remove()
if (atRule.nodes && atRule.nodes.length) {
atRule.replaceWith(atRule.nodes)
} else {
atRule.remove()
}
}

@@ -112,8 +125,14 @@ })

function writeCriticalFile (filePath: string, css: string) {
fs.writeFile(filePath, css, (err: Object) => {
if (err) {
console.error(err)
process.exit(1)
fs.writeFile(
filePath,
css,
{ flag: append ? 'a' : 'w' },
(err: ?ErrnoError) => {
append = true
if (err) {
console.error(err)
process.exit(1)
}
}
})
)
}

@@ -143,2 +162,3 @@

}
append = false
return (css: Object): Object => {

@@ -145,0 +165,0 @@ const { dryRun, preserve, minify, outputPath, outputDest } = args

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc