@lolyjs/core 0.3.0-alpha.4 → 0.3.0-alpha.6

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/README.md CHANGED
@@ -43,6 +43,7 @@ Loly is a full-stack React framework that combines the simplicity of file-based
43
43
  - 🛡️ **Security First** - Built-in rate limiting, validation, sanitization, and security headers
44
44
  - ⚡ **Performance** - Fast bundling with Rspack and optimized code splitting
45
45
  - 📦 **Full ESM Support** - Native ES modules with top-level await, dynamic imports, and `import.meta.url`
46
+ - 🖼️ **Image Optimization** - Automatic image optimization with WebP/AVIF support, lazy loading, and responsive images
46
47
 
47
48
  ---
48
49
 
@@ -848,6 +849,79 @@ export default {
848
849
  } satisfies Partial<FrameworkConfig>;
849
850
  ```
850
851
 
852
+ ### 🖼️ Image Optimization
853
+
854
+ Loly includes a powerful image optimization system similar to Next.js Image, with automatic optimization, lazy loading, responsive images, and remote image support.
855
+
856
+ **Basic Usage:**
857
+
858
+ ```tsx
859
+ import { Image } from "@lolyjs/core/components";
860
+
861
+ export default function MyPage() {
862
+ return (
863
+ <Image
864
+ src="/assets/hero.jpg"
865
+ alt="Hero image"
866
+ width={800}
867
+ height={600}
868
+ />
869
+ );
870
+ }
871
+ ```
872
+
873
+ **Remote Images:**
874
+
875
+ ```tsx
876
+ <Image
877
+ src="https://images.unsplash.com/photo-123"
878
+ alt="Photo"
879
+ width={1200}
880
+ height={800}
881
+ quality={85}
882
+ format="webp"
883
+ />
884
+ ```
885
+
886
+ **Features:**
887
+
888
+ - ✅ Automatic optimization (resize, compress, format conversion)
889
+ - ✅ Modern formats (WebP, AVIF)
890
+ - ✅ Lazy loading by default
891
+ - ✅ Responsive images with automatic srcset
892
+ - ✅ Remote image support (with domain whitelist)
893
+ - ✅ Cache optimization
894
+ - ✅ CLS prevention
895
+
896
+ **Configuration:**
897
+
898
+ Configure allowed remote domains in `loly.config.ts`:
899
+
900
+ ```tsx
901
+ import type { FrameworkConfig } from "@lolyjs/core";
902
+
903
+ export default {
904
+ images: {
905
+ remotePatterns: [
906
+ {
907
+ protocol: "https",
908
+ hostname: "images.unsplash.com",
909
+ },
910
+ {
911
+ protocol: "https",
912
+ hostname: "**.unsplash.com", // Wildcard for subdomains
913
+ },
914
+ ],
915
+ formats: ["image/webp", "image/avif"],
916
+ quality: 75,
917
+ deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
918
+ imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
919
+ },
920
+ } satisfies Partial<FrameworkConfig>;
921
+ ```
922
+
923
+ For complete documentation, see [Image Optimization Documentation](https://github.com/MenvielleValen/loly-framework/blob/main/docs/17-image-optimization.md).
924
+
851
925
  ### 🔌 API Routes
852
926
 
853
927
  Create RESTful APIs with flexible middleware support: