esbuild-plugin-inline-image
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -20,2 +20,4 @@ const { stat, readFile } = require("fs/promises"); | ||
? 0 | ||
: options.limit === -1 || options.limit === "-1" | ||
? -1 | ||
: parseInt(options.limit, 10) || | ||
@@ -52,3 +54,6 @@ parseInt(process.env.IMAGE_INLINE_SIZE_LIMIT || defLimit, 10) || | ||
let loader = "file"; | ||
if (typeof limit === "function") { | ||
if (limit === -1) { | ||
contents = await readFile(args.path); | ||
loader = "dataurl"; | ||
} else if (typeof limit === "function") { | ||
const r = limit(args); | ||
@@ -55,0 +60,0 @@ if ( |
{ | ||
"name": "esbuild-plugin-inline-image", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/natrim/esbuild-plugin-inline-image.git", |
@@ -7,2 +7,4 @@ # esbuild-plugin-inline-image | ||
*Well, technically can be used even for non images (just set the right extensions), but who would want that?* | ||
## Instalation | ||
@@ -61,2 +63,3 @@ | ||
- limit can also be set from env as `IMAGE_INLINE_SIZE_LIMIT` | ||
- setting limit to 0 disables inlining, -1 will always inline | ||
- in case you pass function, the image will be inlined if it returns `true` (or `Promise` that resolves to `true`) | ||
@@ -71,3 +74,3 @@ - the function get's passed `onLoad` [args](https://esbuild.github.io/plugins/#load-arguments) | ||
## Extras | ||
## Examples | ||
@@ -115,3 +118,3 @@ Use plugin multiple times to have different size for different extensions | ||
Use function to inline all images | ||
Set limit to -1 to inline all images | ||
@@ -124,3 +127,3 @@ ```js | ||
inlineImage({ | ||
limit: () => true | ||
limit: -1 | ||
}) | ||
@@ -127,0 +130,0 @@ ] |
8530
99
148