@son426/vite-image 0.1.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +45 -5
  3. package/package.json +1 -1
package/LICENSE CHANGED
@@ -23,3 +23,4 @@ SOFTWARE.
23
23
 
24
24
 
25
25
 
26
+
package/README.md CHANGED
@@ -21,13 +21,51 @@ Simply add the plugin to your config, and start using the `<Image />` component
21
21
 
22
22
  Add it to `vite.config.ts`, and use it like this:
23
23
 
24
+ **Option 1: Using query string (default)**
25
+
24
26
  ```tsx
25
27
  // vite.config.ts
26
- viteImage({
27
- autoApply: {
28
- extensions: [".jpg", ".png", ".webp"],
29
- include: ["src/assets/**"],
30
- },
28
+ import { defineConfig } from "vite";
29
+ import { viteImage } from "@son426/vite-image/plugin";
30
+
31
+ export default defineConfig({
32
+ plugins: [
33
+ viteImage(), // Default breakpoints: [640, 1024, 1920]
34
+ ],
35
+ });
36
+
37
+ // Component
38
+ import Image from "@son426/vite-image/react";
39
+ import myBg from "./assets/background.jpg?vite-image";
40
+
41
+ export default function Page() {
42
+ return (
43
+ <Image
44
+ src={myBg}
45
+ alt="Optimized Background"
46
+ fill
47
+ priority
48
+ placeholder="blur"
49
+ />
50
+ );
51
+ }
52
+ ```
53
+
54
+ **Option 2: Auto-apply without query string**
55
+
56
+ ```tsx
57
+ // vite.config.ts
58
+ import { defineConfig } from "vite";
59
+ import { viteImage } from "@son426/vite-image/plugin";
60
+
61
+ export default defineConfig({
62
+ plugins: [
63
+ viteImage({
64
+ autoApply: {
65
+ extensions: [".jpg"],
66
+ },
67
+ }),
68
+ ],
31
69
  });
32
70
 
33
71
  // Component
@@ -47,6 +85,8 @@ export default function Page() {
47
85
  }
48
86
  ```
49
87
 
88
+ > **Note**: For auto-apply, you'll need to add type declarations. See the [TypeScript Setup](#typescript-setup) section below.
89
+
50
90
  ## Installation
51
91
 
52
92
  Install the package. `vite-imagetools` and `@rollup/pluginutils` are included as dependencies.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@son426/vite-image",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "A Vite plugin and React component for optimized images with LQIP support using vite-imagetools",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",