@squoosh-kit/vite-plugin 0.1.3 → 0.1.4
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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -22
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __require = import.meta.require;
|
|
3
|
-
|
|
4
2
|
// src/index.ts
|
|
5
3
|
import {
|
|
6
4
|
existsSync,
|
|
@@ -10,7 +8,7 @@ import {
|
|
|
10
8
|
rmSync,
|
|
11
9
|
readFileSync
|
|
12
10
|
} from "fs";
|
|
13
|
-
import { join
|
|
11
|
+
import { join } from "path";
|
|
14
12
|
import { searchForWorkspaceRoot } from "vite";
|
|
15
13
|
function copyBrowserFiles(srcDir, destDir) {
|
|
16
14
|
if (!existsSync(srcDir)) {
|
|
@@ -31,34 +29,27 @@ function copyBrowserFiles(srcDir, destDir) {
|
|
|
31
29
|
cpSync(wasmDir, destWasmDir, { recursive: true });
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const packageDir = dirname(packageJsonPath);
|
|
40
|
-
return join(packageDir, "dist");
|
|
41
|
-
} catch (err) {
|
|
42
|
-
console.warn(`[squoosh-vite-plugin] Could not find package "${packageName}". It might not be installed. Skipping asset copy for this package.: ${err}`);
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function squooshVitePlugin() {
|
|
32
|
+
function squooshVitePlugin(squooshKitRoot) {
|
|
33
|
+
const viteRoot = process.cwd();
|
|
34
|
+
const publicDir = join(viteRoot, "public", "squoosh-kit");
|
|
35
|
+
const webpDist = join(squooshKitRoot, "webp", "dist");
|
|
36
|
+
const resizeDist = join(squooshKitRoot, "resize", "dist");
|
|
47
37
|
return {
|
|
48
38
|
name: "squoosh-vite-plugin",
|
|
49
39
|
buildStart() {
|
|
50
40
|
console.log("Copying Squoosh browser assets...");
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
41
|
+
console.log("squooshKitRoot", squooshKitRoot);
|
|
42
|
+
console.log("viteRoot", viteRoot);
|
|
43
|
+
console.log("publicDir", publicDir);
|
|
44
|
+
console.log("webpDist", webpDist);
|
|
45
|
+
console.log("resizeDist", resizeDist);
|
|
55
46
|
if (existsSync(publicDir)) {
|
|
56
47
|
rmSync(publicDir, { recursive: true, force: true });
|
|
57
48
|
}
|
|
58
|
-
if (webpDist) {
|
|
49
|
+
if (existsSync(webpDist)) {
|
|
59
50
|
copyBrowserFiles(webpDist, join(publicDir, "webp"));
|
|
60
51
|
}
|
|
61
|
-
if (resizeDist) {
|
|
52
|
+
if (existsSync(resizeDist)) {
|
|
62
53
|
copyBrowserFiles(resizeDist, join(publicDir, "resize"));
|
|
63
54
|
}
|
|
64
55
|
console.log("Squoosh assets copied successfully!");
|
package/package.json
CHANGED