postcss-js
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -0,1 +1,4 @@ | ||
## 0.3 | ||
* Add support for at-rules with same name (like `@font-face`). | ||
## 0.2 | ||
@@ -2,0 +5,0 @@ * Add `!important` support (by Dan Lynch). |
var camelcase = require('camelcase-css'); | ||
function atRule(node) { | ||
if ( typeof node.nodes === 'undefined' ) { | ||
return true; | ||
} else { | ||
return process(node); | ||
} | ||
} | ||
function process(node) { | ||
@@ -24,6 +32,8 @@ var name; | ||
if ( child.params ) name += ' ' + child.params; | ||
if ( typeof child.nodes === 'undefined' ) { | ||
result[name] = true; | ||
if ( typeof result[name] === 'undefined' ) { | ||
result[name] = atRule(child); | ||
} else if ( Array.isArray(result[name]) ) { | ||
result[name].push(atRule(child)); | ||
} else { | ||
result[name] = process(child); | ||
result[name] = [result[name], atRule(child)]; | ||
} | ||
@@ -30,0 +40,0 @@ |
{ | ||
"name": "postcss-js", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "PostCSS for React Inline Styles, Radium, Free Style and other CSS-in-JS", | ||
@@ -18,9 +18,9 @@ "keywords": [ | ||
"camelcase-css": "^1.0.1", | ||
"postcss": "^5.2.6" | ||
"postcss": "^5.2.14" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^3.12.2", | ||
"eslint": "^3.15.0", | ||
"eslint-config-postcss": "^2.0.2", | ||
"jest": "^18.0.0", | ||
"lint-staged": "^3.2.4", | ||
"jest": "^18.1.0", | ||
"lint-staged": "^3.3.1", | ||
"pre-commit": "^1.2.2" | ||
@@ -48,2 +48,3 @@ }, | ||
"rules": { | ||
"no-use-before-define": "off", | ||
"quote-props": "off" | ||
@@ -50,0 +51,0 @@ }, |
@@ -51,4 +51,13 @@ var postcss = require('postcss'); | ||
function atRule(parent, parts, value) { | ||
var node = postcss.atRule({ name: parts[1], params: parts[3] || '' }); | ||
if ( typeof value === 'object' ) { | ||
node.nodes = []; | ||
parse(value, node); | ||
} | ||
parent.push(node); | ||
} | ||
function parse(obj, parent) { | ||
var name, value, node; | ||
var name, value, node, i; | ||
for ( name in obj ) { | ||
@@ -58,11 +67,12 @@ if ( obj.hasOwnProperty(name) ) { | ||
if ( name[0] === '@' ) { | ||
var part = name.match(/@([^\s]+)(\s+([\w\W]*)\s*)?/); | ||
node = postcss.atRule({ name: part[1], params: part[3] || '' }); | ||
if ( typeof value === 'object' ) { | ||
node.nodes = []; | ||
parse(value, node); | ||
var parts = name.match(/@([^\s]+)(\s+([\w\W]*)\s*)?/); | ||
if ( Array.isArray(value) ) { | ||
for ( i = 0; i < value.length; i++ ) { | ||
atRule(parent, parts, value[i]); | ||
} | ||
} else { | ||
atRule(parent, parts, value); | ||
} | ||
parent.push(node); | ||
} else if ( Array.isArray(value) ) { | ||
for ( var i = 0; i < value.length; i++ ) { | ||
for ( i = 0; i < value.length; i++ ) { | ||
decl(parent, name, value[i]); | ||
@@ -69,0 +79,0 @@ } |
@@ -120,14 +120,1 @@ # PostCSS JS [![Build Status][ci-img]][ci] | ||
``` | ||
### `Cannot resolve module 'fs'` | ||
By default, webpack resolve system node.js modules to empty file. | ||
But `node` option in webpack config can disable it. | ||
If it is your case, please add to webpack config: | ||
```js | ||
node: { | ||
fs: "empty" | ||
} | ||
``` |
10802
173
120
Updatedpostcss@^5.2.14