Skip to content

Commit 8b6f222

Browse files
committed
Merge branch 'v0.0.6'
2 parents f93c368 + 901de02 commit 8b6f222

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ import sassStyleObject from '!css-object!sass!./styles.scss';
9999

100100
This allows you to introduce `css-object-loader` into your projects without making breaking changes.
101101

102+
__NOTE__: If you import a CSS file with `:local(...)` selectors, the selector object will include the `:local(...)` string.
103+
102104
##### Preprocessors
103105

104106
If you want to use `css-object-loader` with LESS or SASS, make sure the preprocessor loader runs before `css-object-loader`. Webpack evaluates loaders right to left. Example config for SASS:

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,16 @@ function getParsedStylesheet(source) {
2525
function isValidRule(rule) {
2626
return !!(rule.type === 'rule' && rule.selectors && rule.selectors.length);
2727
}
28+
// Return `true` for an AST node with { type: 'declaration' } and any property
29+
function isValidDeclaration (declaration) {
30+
return !!(declaration.type === 'declaration' && declaration.property && declaration.property.length);
31+
}
2832

2933
// Reduce a declaration node from the AST to a style object
3034
function reduceDeclarationsToStyleObject(styleObj, declaration) {
35+
if (!isValidDeclaration(declaration)) {
36+
return styleObj;
37+
}
3138
var key = camelCase(declaration.property);
3239
var value = declaration.value;
3340
styleObj[key] = value;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-object-loader",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"author": "pl12133",
55
"description": "Webpack loader to load CSS into a selector object with camelCased properties",
66
"main": "index.js",

0 commit comments

Comments
 (0)