Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-csso

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-csso - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

6

HISTORY.md

@@ -0,4 +1,8 @@

## 1.1.0 (April 7, 2016)
- Migrate to [CSSO 2.0](https://github.com/css/csso/releases/tag/v2.0.0)
## 1.0.1 (March 19, 2016)
- Internal refactoring and minor fixes
- Refactoring and minor fixes

@@ -5,0 +9,0 @@ ## 1.0.0 (March 16, 2016)

10

index.js

@@ -7,12 +7,4 @@ var postcss = require('postcss');

var postcssCsso = postcss.plugin('postcss-csso', function postcssCsso(options) {
// force set outputAst:internal to options until csso need it for backward capability
// TODO: remove it when possible
options = Object.create(options && typeof options === 'object' ? options : null, {
outputAst: {
value: 'internal'
}
});
return function(root, result) {
result.root = cssoToPostcss(compress(postcssToCsso(root), options));
result.root = cssoToPostcss(compress(postcssToCsso(root), options).ast);
};

@@ -19,0 +11,0 @@ });

var postcss = require('postcss');
var translate = require('csso').internal.translate;
var translate = require('csso').translate;
var hasOwnProperty = Object.prototype.hasOwnProperty;

@@ -23,3 +23,3 @@

function clone(source) {
var result = {};
var result = Object.create(Object.getPrototypeOf(source));

@@ -26,0 +26,0 @@ for (var key in source) {

@@ -7,53 +7,62 @@ var parse = require('csso').parse;

function appendNodes(cssoNode, postcssNode) {
cssoNode.push.apply(cssoNode, postcssNode.nodes.map(postcssToCsso));
function appendNodes(cssoNode, listProperty, postcssNode) {
var list = cssoNode[listProperty];
postcssNode.nodes.forEach(function(node) {
list.insert(list.createItem(postcssToCsso(node)));
});
return cssoNode;
}
function postcssToCsso(node) {
function parseToCsso(str, scope, node) {
var cssoNode = parse(str, scope, {
needInfo: true
});
function getInfo(node) {
return {
postcssNode: node
};
}
cssoNode[0] = getInfo(node);
function parseToCsso(str, context, node) {
var cssoNode = parse(str, {
context: context
});
return cssoNode;
}
cssoNode.info = getInfo(node);
function getInfo(node) {
return {
postcssNode: node
};
}
return cssoNode;
}
function createCssoNode(type, property, node) {
return appendNodes(parseToCsso('', type, node), property, node);
}
function postcssToCsso(node) {
switch (node.type) {
case 'root':
return appendNodes([getInfo(node), 'stylesheet'], node);
return createCssoNode('stylesheet', 'rules', node);
case 'rule':
return [
getInfo(node),
'ruleset',
node.selector ? parseToCsso(node.selector, 'selector', node) : [getInfo(node), 'selector'],
appendNodes([{}, 'block'], node)
];
return {
type: 'Ruleset',
info: getInfo(node),
selector: parseToCsso(node.selector || '', 'selector', node),
block: createCssoNode('block', 'declarations', node)
};
case 'atrule':
var atruleStr = '@' + node.name + ' ' + node.params;
var cssoNode = {
type: 'Atrule',
info: getInfo(node),
name: node.name,
expression: parseToCsso(node.params, 'atruleExpression', node),
block: null
};
if (node.nodes) {
if (node.nodes.some(isDecl)) {
atruleStr += '{}';
cssoNode.block = createCssoNode('block', 'declarations', node);
} else {
atruleStr += '{a{}}';
cssoNode.block = createCssoNode('stylesheet', 'rules', node);
}
}
var cssoNode = parseToCsso(atruleStr, 'atruler', node);
if (node.nodes) {
appendNodes(cssoNode[cssoNode.length - 1], node);
}
return cssoNode;

@@ -71,7 +80,7 @@

case 'comment':
return [
getInfo(node),
'comment',
node.raws.left + node.text + node.raws.right
];
return {
type: 'Comment',
info: getInfo(node),
value: node.raws.left + node.text + node.raws.right
};
}

@@ -78,0 +87,0 @@ }

{
"name": "postcss-csso",
"version": "1.0.1",
"version": "1.1.0",
"description": "PostCSS plugin to minify CSS using CSSO",

@@ -36,6 +36,9 @@ "keywords": [

"test": "jscs . && eslint . && mocha",
"travis": "npm run test"
"test": "mocha --reporter dot",
"codestyle": "jscs lib && eslint lib test",
"codestyle-and-test": "npm run codestyle && npm test",
"travis": "npm run codestyle-and-test"
},
"dependencies": {
"csso": "^1.7.0",
"csso": "^2.0.0",
"postcss": "^5.0.0"

@@ -42,0 +45,0 @@ },

@@ -34,8 +34,11 @@ [![NPM version](https://img.shields.io/npm/v/postcss-csso.svg)](https://www.npmjs.com/package/postcss-csso)

});
```
// you also can pass an options
Plugin accepts the same [options](https://github.com/css/csso#minifysource-options) as `minify()` method of CSSO with no any changes.
```js
postcss([
csso({ restructure: false })
])
.process('.a { color: red; } .b { color: red; }')
.process('.a { color: #FF0000; } .b { color: rgba(255, 0, 0, 1) }')
.then(function(result) {

@@ -42,0 +45,0 @@ console.log(result.css);

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc