vite-plugin-build-version-file 0.1.14 → 0.1.15

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
@@ -390,7 +390,7 @@ import { clearUrlCache } from 'vite-plugin-build-version-file/client'
390
390
  await clearUrlCache('/vue-app/')
391
391
  ```
392
392
 
393
- `url` 可省略;省略时默认使用当前 Vue 项目页面 URL:
393
+ `url` 可省略;省略时默认使用 `location.origin + location.pathname`,不包含当前 query/hash:
394
394
 
395
395
  ```ts
396
396
  await clearUrlCache()
@@ -856,7 +856,7 @@ import { clearUrlCache } from 'vite-plugin-build-version-file/client'
856
856
  await clearUrlCache('/vue-app/')
857
857
  ```
858
858
 
859
- The `url` argument is optional. When omitted, the current Vue project page URL is used:
859
+ The `url` argument is optional. When omitted, `location.origin + location.pathname` is used without the current query/hash:
860
860
 
861
861
  ```ts
862
862
  await clearUrlCache()
@@ -865,7 +865,7 @@ await clearUrlCache()
865
865
  Vue hash routes are preserved. The cache-busting timestamp is added before `#` so the server receives it:
866
866
 
867
867
  ```text
868
- https://cus.smarex.com.cn/pc/?_=random-value#/login?redirect=/dashboard/analysis
868
+ https://xxx.cn/pc/?_=random-value#/login?redirect=/dashboard/analysis
869
869
  ```
870
870
 
871
871
  This method only supports same-origin URLs. It bypasses the cached URL, forces a refresh of the original URL, loads the page again in a hidden iframe, and finally navigates to the URL with a random timestamp. Any existing cache-refresh iframe created by this method is removed before a new one is created. A failed request or iframe load does not prevent the final navigation.
package/dist/client.cjs CHANGED
@@ -59,8 +59,9 @@ function loadIframe(url) {
59
59
  document.documentElement.appendChild(iframe);
60
60
  });
61
61
  }
62
- async function clearUrlCache(url = window.location.href) {
62
+ async function clearUrlCache(url = window.location.origin + window.location.pathname) {
63
63
  const targetUrl = new URL(url, window.location.href).href;
64
+ console.info(`[vite-plugin-build-version] Clear cache for ${targetUrl}`);
64
65
  await Promise.allSettled([
65
66
  fetch(createCacheBustedUrl(targetUrl), { cache: "no-store" }).then(
66
67
  (response) => response.arrayBuffer()
package/dist/client.mjs CHANGED
@@ -35,8 +35,9 @@ function loadIframe(url) {
35
35
  document.documentElement.appendChild(iframe);
36
36
  });
37
37
  }
38
- async function clearUrlCache(url = window.location.href) {
38
+ async function clearUrlCache(url = window.location.origin + window.location.pathname) {
39
39
  const targetUrl = new URL(url, window.location.href).href;
40
+ console.info(`[vite-plugin-build-version] Clear cache for ${targetUrl}`);
40
41
  await Promise.allSettled([
41
42
  fetch(createCacheBustedUrl(targetUrl), { cache: "no-store" }).then(
42
43
  (response) => response.arrayBuffer()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-build-version-file",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "A Vite plugin that emits version.json and injects version metadata into HTML.",
5
5
  "license": "MIT",
6
6
  "type": "module",