@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.
- package/LICENSE +1 -0
- package/README.md +45 -5
- package/package.json +1 -1
package/LICENSE
CHANGED
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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