@squoosh-kit/vite-plugin 0.1.5 → 0.1.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/dist/index.d.ts CHANGED
@@ -16,16 +16,6 @@ export default function squooshVitePlugin(squooshKitRoot: string): {
16
16
  exclude: string[];
17
17
  };
18
18
  assetsInclude: string[];
19
- build: {
20
- rollupOptions: {
21
- output: {
22
- assetFileNames: (assetInfo: {
23
- name?: string;
24
- }) => "assets/[name].[ext]" | "assets/[name]-[hash].[ext]";
25
- };
26
- };
27
- };
28
19
  };
29
- configureServer(this: import("vite").MinimalPluginContextWithoutEnvironment, server: import("vite").ViteDevServer): void;
30
20
  };
31
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA0CA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;gDA8CxB;wBAAE,IAAI,CAAC,EAAE,MAAM,CAAA;qBAAE;;;;;;EA2DxD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmCA,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,cAAc,EAAE,MAAM;;;;;;;;;;;;;;;;;;;EA6C/D"}
package/dist/index.js CHANGED
@@ -1,13 +1,6 @@
1
1
  // @bun
2
2
  // src/index.ts
3
- import {
4
- existsSync,
5
- mkdirSync,
6
- cpSync,
7
- readdirSync,
8
- rmSync,
9
- readFileSync
10
- } from "fs";
3
+ import { existsSync, mkdirSync, cpSync, readdirSync, rmSync } from "fs";
11
4
  import { join } from "path";
12
5
  import { searchForWorkspaceRoot } from "vite";
13
6
  function copyBrowserFiles(srcDir, destDir) {
@@ -68,52 +61,8 @@ function squooshVitePlugin(squooshKitRoot) {
68
61
  optimizeDeps: {
69
62
  exclude: ["@squoosh-kit/webp", "@squoosh-kit/resize"]
70
63
  },
71
- assetsInclude: ["**/*.wasm"],
72
- build: {
73
- rollupOptions: {
74
- output: {
75
- assetFileNames: (assetInfo) => {
76
- if (assetInfo.name?.endsWith(".wasm")) {
77
- return "assets/[name].[ext]";
78
- }
79
- return "assets/[name]-[hash].[ext]";
80
- }
81
- }
82
- }
83
- }
84
- }),
85
- configureServer(server) {
86
- server.middlewares.use((req, res, next) => {
87
- const url = req.url;
88
- if (!url?.includes(".wasm")) {
89
- next();
90
- return;
91
- }
92
- try {
93
- const workspaceRoot = searchForWorkspaceRoot(process.cwd());
94
- const cleanUrl = url.split("?")[0];
95
- const urlPath = cleanUrl?.startsWith("/") ? cleanUrl.slice(1) : cleanUrl;
96
- const pathsToTry = [
97
- join(workspaceRoot, urlPath ?? ""),
98
- urlPath?.includes("@squoosh-kit/wasm/") ? join(workspaceRoot, urlPath.replace(/node_modules\/@squoosh-kit\/wasm\//, "node_modules/@squoosh-kit/webp/dist/wasm/")) : null
99
- ].filter((p) => p !== null);
100
- for (const filePath of pathsToTry) {
101
- try {
102
- const wasmData = readFileSync(filePath);
103
- res.setHeader("Content-Type", "application/wasm");
104
- res.setHeader("Cross-Origin-Embedder-Policy", "require-corp");
105
- res.setHeader("Cross-Origin-Opener-Policy", "same-origin");
106
- res.setHeader("Content-Length", wasmData.length.toString());
107
- res.end(wasmData);
108
- return;
109
- } catch {}
110
- }
111
- next();
112
- } catch {
113
- next();
114
- }
115
- });
116
- }
64
+ assetsInclude: ["**/*.wasm"]
65
+ })
117
66
  };
118
67
  }
119
68
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squoosh-kit/vite-plugin",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "description": "Vite plugin for Squoosh Kit - handles asset copying and WASM configuration",
6
6
  "author": "Bartosz Nowak <bnowak008@gmail.com>",