vite-plugin-cross-origin-storage 1.3.2 → 1.3.3

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.
Files changed (2) hide show
  1. package/dist/index.js +7 -2
  2. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -1622,10 +1622,14 @@ function cosPlugin(options = {}) {
1622
1622
  const filter = createFilter(options.include || ["**/*"], options.exclude);
1623
1623
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
1624
1624
  const loaderPath = path.resolve(__dirname, "./loader.js");
1625
+ let config;
1625
1626
  return {
1626
1627
  name: "vite-plugin-cos",
1627
1628
  apply: "build",
1628
1629
  enforce: "post",
1630
+ configResolved(resolvedConfig) {
1631
+ config = resolvedConfig;
1632
+ },
1629
1633
  transformIndexHtml: {
1630
1634
  order: "post",
1631
1635
  handler(html) {
@@ -1711,14 +1715,15 @@ function cosPlugin(options = {}) {
1711
1715
  for (const fileName in chunkInfo) {
1712
1716
  const { chunk, globalVar } = chunkInfo[fileName];
1713
1717
  const finalHash = crypto.createHash("sha256").update(chunk.code).digest("hex");
1718
+ const base = config.base.endsWith("/") ? config.base : config.base + "/";
1714
1719
  manifest[fileName] = {
1715
- file: `/${fileName}`,
1720
+ file: `${base}${fileName}`,
1716
1721
  hash: finalHash,
1717
1722
  globalVar
1718
1723
  };
1719
1724
  }
1720
1725
  manifest["index"] = {
1721
- file: `/${mainChunk.fileName}`
1726
+ file: `${config.base.endsWith("/") ? config.base : config.base + "/"}${mainChunk.fileName}`
1722
1727
  };
1723
1728
  if (htmlAsset) {
1724
1729
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-cross-origin-storage",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Vite plugin to load chunks from Cross-Origin Storage",
5
5
  "keywords": [
6
6
  "vite",
@@ -35,7 +35,8 @@
35
35
  "loader.js"
36
36
  ],
37
37
  "scripts": {
38
- "build": "tsup index.ts --format esm --dts --clean && cp loader.js dist/"
38
+ "build": "tsup index.ts --format esm --dts --clean && cp loader.js dist/",
39
+ "prepublishOnly": "npm run build"
39
40
  },
40
41
  "peerDependencies": {
41
42
  "vite": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"