vitepress-plugin-responsive-images 0.1.0 → 0.1.1
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 +12 -0
- package/dist/index.js +21 -6
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -107,6 +107,18 @@ responsiveImages: false
|
|
|
107
107
|
---
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
## Releasing
|
|
111
|
+
|
|
112
|
+
This project uses Changesets and npm Trusted Publishing.
|
|
113
|
+
|
|
114
|
+
For user-facing changes, add a changeset before opening a pull request:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npm run changeset
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
When changes are merged into `main`, the release workflow creates a `Version Packages` pull request. Merging that pull request publishes the package to npm and creates the GitHub release through Trusted Publishing.
|
|
121
|
+
|
|
110
122
|
## License
|
|
111
123
|
|
|
112
124
|
MIT
|
package/dist/index.js
CHANGED
|
@@ -336,13 +336,11 @@ function responsiveImagesVitePlugin(runtime) {
|
|
|
336
336
|
name: "vitepress-plugin-responsive-images",
|
|
337
337
|
async configResolved(config) {
|
|
338
338
|
resolvedConfig = config;
|
|
339
|
-
runtime
|
|
340
|
-
runtime
|
|
341
|
-
runtime.cacheDir = path4.join(config.cacheDir, "responsive-images");
|
|
342
|
-
runtime.outDir = config.build.outDir;
|
|
339
|
+
applyResolvedConfig(runtime, config);
|
|
340
|
+
await ensureManifest(runtime);
|
|
343
341
|
},
|
|
344
342
|
async buildStart() {
|
|
345
|
-
await
|
|
343
|
+
await ensureManifest(runtime);
|
|
346
344
|
},
|
|
347
345
|
resolveId(source) {
|
|
348
346
|
const fileName = getGeneratedFileName(source, runtime);
|
|
@@ -354,8 +352,11 @@ function responsiveImagesVitePlugin(runtime) {
|
|
|
354
352
|
return `export default ${JSON.stringify(joinUrl(runtime.base, runtime.options.outputDir, fileName))}`;
|
|
355
353
|
},
|
|
356
354
|
async configureServer(server) {
|
|
357
|
-
await
|
|
355
|
+
await ensureManifest(runtime);
|
|
358
356
|
installDevMiddleware(server, runtime);
|
|
357
|
+
server.watcher.on("change", async () => {
|
|
358
|
+
await rebuildManifest(runtime);
|
|
359
|
+
});
|
|
359
360
|
},
|
|
360
361
|
async closeBundle() {
|
|
361
362
|
if (!resolvedConfig) return;
|
|
@@ -363,6 +364,20 @@ function responsiveImagesVitePlugin(runtime) {
|
|
|
363
364
|
}
|
|
364
365
|
};
|
|
365
366
|
}
|
|
367
|
+
function applyResolvedConfig(runtime, config) {
|
|
368
|
+
runtime.root = config.root;
|
|
369
|
+
runtime.base = config.base || "/";
|
|
370
|
+
runtime.cacheDir = path4.join(config.cacheDir, "responsive-images");
|
|
371
|
+
runtime.outDir = config.build.outDir;
|
|
372
|
+
}
|
|
373
|
+
async function ensureManifest(runtime) {
|
|
374
|
+
if (!runtime.built) {
|
|
375
|
+
await rebuildManifest(runtime);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
async function rebuildManifest(runtime) {
|
|
379
|
+
await buildManifest(runtime);
|
|
380
|
+
}
|
|
366
381
|
function getGeneratedFileName(source, runtime) {
|
|
367
382
|
const normalizedBase = runtime.base === "/" ? "" : runtime.base.replace(/\/+$/g, "");
|
|
368
383
|
const prefixes = [`/${runtime.options.outputDir}/`];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitepress-plugin-responsive-images",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Automatically convert local Markdown images in VitePress docs into responsive picture elements.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,10 @@
|
|
|
44
44
|
"test": "vitest run",
|
|
45
45
|
"test:watch": "vitest",
|
|
46
46
|
"test:integration": "vitest run tests/integration.test.ts",
|
|
47
|
-
"prepublishOnly": "npm run typecheck && npm run test && npm run build"
|
|
47
|
+
"prepublishOnly": "npm run typecheck && npm run test && npm run build",
|
|
48
|
+
"changeset": "changeset",
|
|
49
|
+
"version": "changeset version",
|
|
50
|
+
"release": "npm run typecheck && npm run test && npm run build && changeset publish"
|
|
48
51
|
},
|
|
49
52
|
"peerDependencies": {
|
|
50
53
|
"vitepress": "^1.6.0 || ^2.0.0-alpha || ^2.0.0",
|
|
@@ -55,6 +58,8 @@
|
|
|
55
58
|
"tinyglobby": "^0.2.17"
|
|
56
59
|
},
|
|
57
60
|
"devDependencies": {
|
|
61
|
+
"@changesets/changelog-github": "^0.7.0",
|
|
62
|
+
"@changesets/cli": "^2.31.0",
|
|
58
63
|
"@types/markdown-it": "^14.1.2",
|
|
59
64
|
"@types/node": "^25.9.3",
|
|
60
65
|
"markdown-it": "^14.2.0",
|
|
@@ -63,5 +68,6 @@
|
|
|
63
68
|
"vitepress": "^1.6.4",
|
|
64
69
|
"vitest": "^4.1.9",
|
|
65
70
|
"vue": "^3.5.38"
|
|
66
|
-
}
|
|
71
|
+
},
|
|
72
|
+
"packageManager": "npm@11.12.1"
|
|
67
73
|
}
|