You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-13Lines changed: 21 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
# css-object-loader
6
6
7
-
Webpack loader to load CSS into a selector object with camelCased properties. Load a CSS file and it will return an object with keys that are the selectors from that CSS file. Each selector has an object containing the rules declared in your CSS.
7
+
Webpack loader to load CSS into an object. The object has keys that are selectors from the CSS file; the value of each selector are the rules converted to camelCase properties ([see Style Object Properties](http://www.w3schools.com/jsref/dom_obj_style.asp)). This object is compatible with [React Inline Styles](https://facebook.github.io/react/tips/inline-styles.html).
8
8
9
9
## Install
10
10
@@ -17,14 +17,14 @@ Webpack loader to load CSS into a selector object with camelCased properties. Lo
17
17
Create an entry to load `.css` files in your webpack.config:
1. You want to inline all your styles, but you still want to write your CSS into CSS files.
83
+
2. You want to use a CSS preprocessor to write your inline styles.
84
+
81
85
### Multiple Loaders
82
86
83
87
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:
84
88
85
89
```js
86
90
module: {
87
91
loaders: [{
88
-
test:/\.scss/,
92
+
test:/\.scss$/,
89
93
loaders: [ 'css-object', 'sass' ],
90
94
exclude:/node_modules/
91
95
}]
@@ -94,7 +98,11 @@ module: {
94
98
95
99
## Limitations
96
100
97
-
This library uses [reworkcss/css](https://github.com/reworkcss/css) to parse CSS. It is currently a proof of concept and not intended for production usage. This loader should function with other CSS preprocessors as long as they run before `css-object-loader`. The underlying concept is still a work in progress, if you have any suggestions please feel free to open an issue.
101
+
This library is currently a proof of concept and not intended for production usage. This loader should function with other CSS preprocessors as long as they run before `css-object-loader`. The underlying concept is still a work in progress, if you have any suggestions please feel free to open an issue.
102
+
103
+
## Implementation
104
+
105
+
This library uses [reworkcss/css](https://github.com/reworkcss/css) to parse CSS to an AST. The AST is then traversed to find rule declarations and populate them into an object. Media queries are ignored.
0 commit comments