vite-imagetools
Advanced tools
Comparing version 4.0.4 to 4.0.5
@@ -16,3 +16,25 @@ import { TransformFactory, OutputFormat, resolveConfigs } from 'imagetools-core'; | ||
* This option allows you to specify directives that should be applied _by default_ to every image. | ||
* You can also provide a function, in which case the function gets passed the asset ID and should return an object of directives | ||
* You can also provide a function, in which case the function gets passed the asset ID and should return an object of directives. | ||
* This can be used to define all sorts of shorthands or presets. | ||
* | ||
* @example | ||
* ```js | ||
* import { defineConfig } from 'vite' | ||
* import { imagetools } from 'vite-imagetools' | ||
* | ||
* export default defineConfig({ | ||
* plugins: [ | ||
* imagetools({ | ||
* defaultDirectives: (url) => { | ||
* if (url.searchParams.has('spotify')) { | ||
* return new URLSearchParams({ | ||
* tint: 'ffaa22' | ||
* }) | ||
* } | ||
* return new URLSearchParams() | ||
* } | ||
* }) | ||
* ] | ||
* }) | ||
* ``` | ||
*/ | ||
@@ -19,0 +41,0 @@ defaultDirectives?: URLSearchParams | ((url: URL) => URLSearchParams); |
{ | ||
"name": "vite-imagetools", | ||
"description": "Load and transform images using a toolbox of import directives!", | ||
"version": "4.0.4", | ||
"version": "4.0.5", | ||
"main": "dist/index.cjs", | ||
@@ -36,16 +36,16 @@ "module": "dist/index.mjs", | ||
"@types/jest": "^28.0.0", | ||
"@types/jest-image-snapshot": "^4.3.1", | ||
"@types/jsdom": "^16.2.14", | ||
"@types/jest-image-snapshot": "^5.0.0", | ||
"@types/jsdom": "^20.0.0", | ||
"@types/picomatch": "^2.3.0", | ||
"jest": "^28.0.0", | ||
"@types/sharp": "^0.30.0", | ||
"@vitest/coverage-c8": "^0.22.1", | ||
"jest-image-snapshot": "^5.0.0", | ||
"jsdom": "^19.0.0", | ||
"jsdom": "^20.0.0", | ||
"picomatch": "^2.3.1", | ||
"rollup": "^2.66.1", | ||
"sharp": "^0.30.0", | ||
"ts-jest": "^28.0.0", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.5.5", | ||
"vite": "^2.7.13" | ||
"vite": "^3.0.9", | ||
"vitest": "^0.22.1" | ||
}, | ||
@@ -55,5 +55,5 @@ "scripts": { | ||
"build": "rollup -c", | ||
"test": "jest", | ||
"coverage": "jest --collectCoverage" | ||
"test": "vitest run", | ||
"coverage": "vitest run --coverage" | ||
} | ||
} |
@@ -63,7 +63,25 @@ # vite-imagetools | ||
This option allows you to specify directives that should be applied _by default_ to every image. | ||
You can also provide a function, in which case the function gets passed the asset ID and should return an object of directives | ||
You can also provide a function, in which case the function gets passed the asset ID and should return an object of directives. | ||
This can be used to define all sorts of shorthands or presets. | ||
#### Defined in | ||
**`example`** | ||
```js | ||
import { defineConfig } from 'vite' | ||
import { imagetools } from 'vite-imagetools' | ||
[vite/src/types.ts:20](https://github.com/JonasKruckenberg/imagetools/blob/edbc774/packages/vite/src/types.ts#L20) | ||
export default defineConfig({ | ||
plugins: [ | ||
imagetools({ | ||
defaultDirectives: (url) => { | ||
if (url.searchParams.has('spotify')) { | ||
return new URLSearchParams({ | ||
tint: 'ffaa22' | ||
}) | ||
} | ||
return new URLSearchParams() | ||
} | ||
}) | ||
] | ||
}) | ||
``` | ||
@@ -81,6 +99,2 @@ ___ | ||
#### Defined in | ||
[vite/src/types.ts:14](https://github.com/JonasKruckenberg/imagetools/blob/4253c96/packages/vite/src/types.ts#L14) | ||
___ | ||
@@ -97,6 +111,2 @@ | ||
#### Defined in | ||
[vite/src/types.ts:8](https://github.com/JonasKruckenberg/imagetools/blob/4253c96/packages/vite/src/types.ts#L8) | ||
___ | ||
@@ -112,6 +122,2 @@ | ||
#### Defined in | ||
[vite/src/types.ts:46](https://github.com/JonasKruckenberg/imagetools/blob/4253c96/packages/vite/src/types.ts#L46) | ||
___ | ||
@@ -127,6 +133,2 @@ | ||
#### Defined in | ||
[vite/src/types.ts:40](https://github.com/JonasKruckenberg/imagetools/blob/4253c96/packages/vite/src/types.ts#L40) | ||
### extendOutputFormats | ||
@@ -151,6 +153,2 @@ | ||
#### Defined in | ||
[vite/src/types.ts:34](https://github.com/JonasKruckenberg/imagetools/blob/4253c96/packages/vite/src/types.ts#L34) | ||
___ | ||
@@ -203,6 +201,2 @@ | ||
#### Defined in | ||
[vite/src/types.ts:40](https://github.com/JonasKruckenberg/imagetools/blob/edbc774/packages/vite/src/types.ts#L40) | ||
## Contributing | ||
@@ -209,0 +203,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
42247
318
203