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
+60-12
Original file line number
Diff line number
Diff line change
@@ -134,9 +134,57 @@ import { enableReactOptimization } from 'used-styles';
134
134
enableReactOptimization(); // just makes it a but faster
135
135
```
136
136
137
+
## Serialize API
138
+
139
+
Use it to separate generation of styles lookup from your runtime.
140
+
141
+
It is useful in cases, where you can't directly use Discovery APIs on your client CSS bundles during app's runtime, e.g. various serverless runtimes.
142
+
Also it may be useful for you, if you want to save on the size of your container for the server app, since it allows you to only load styles lookup into it, without CSS bundles.
143
+
144
+
1.`serializeStylesLookup(def: StyleDef): SerializedStyleDef` - creates a serializable object from original styles lookup. Result can be then stringified with `JSON.stringify`
145
+
2.`loadSerializedLookup(def: SerializedStyleDef): StyleDef` - transforms serialized style definition back to normal `StyleDef`, which can be used with any Scanner API
146
+
147
+
### Example
148
+
149
+
#### During your build
150
+
151
+
1. Add separate script to generate style lookup and store it as you like.
0 commit comments