lz-string for webpack
Compresses a string and then decompresses it at runtime Ideal for large JSONs and large CSS files when gzip or serverside compression is not an option.
npm install lzstring-loader
Plain old string
var string = require("lzstring!./a.txt");
JSON (with json-loader)
var json = require("lzstring!json!./a.json");
CSS (with style-loader)
require("style!lzstring!./a.css");
Use other lzstring methods with the query param to
require("style!lzstring?to=utf16!./a.css");
The default is (compress/decompress)(To/From)Base64
- base64: (compress/decompress)(To/From)Base64
- utf16: (compress/decompress)(To/From)UTF16
- webkit-utf16: (compress/decompress)
- uri: (compress/decompress)(To/From)EncodedURIComponent
- uint8: (compress/decompress)(To/From)Uint8Array
eg:
var json = require("json!lzstring!./a.json");