fix(ci): vendor @yunhai/vite-plugin-theme 进仓,修 CI npm ci 解析不到 file:../../YschTheme
build / build (push) Successful in 2m34s

- CI 只 clone NoticeFront,file:../../YschTheme/packages/vite-plugin 在容器里不存在 → npm ci 秒失败(run#13)。
- 改为仓内 plugins/vite-plugin-theme(拷构建产物,dist→lib 规避 .gitignore 的 dist 规则;剥离 devDeps 防嵌套安装)。
- package.json 消费改 file:./plugins/vite-plugin-theme,重生成 lock(已清 extraneous 孤儿)。
- 本地 npm run build 通过。待 Nexus npm 仓就绪后再迁回版本号消费(方案 B)。
This commit is contained in:
chenxing
2026-09-24 12:22:09 +08:00
parent 796a1b9a7b
commit 21a0bd36b6
7 changed files with 1209 additions and 17 deletions
+788 -16
View File
@@ -33,7 +33,7 @@
"@unocss/preset-rem-to-px": "^66.6.0", "@unocss/preset-rem-to-px": "^66.6.0",
"@unocss/preset-uno": "^66.6.0", "@unocss/preset-uno": "^66.6.0",
"@vitejs/plugin-vue": "^5.0.4", "@vitejs/plugin-vue": "^5.0.4",
"@yunhai/vite-plugin-theme": "file:../../YschTheme/packages/vite-plugin", "@yunhai/vite-plugin-theme": "file:./plugins/vite-plugin-theme",
"fast-glob": "^3.3.2", "fast-glob": "^3.3.2",
"typescript": "^5.2.2", "typescript": "^5.2.2",
"unocss": "^66.6.0", "unocss": "^66.6.0",
@@ -44,20 +44,6 @@
"vue-tsc": "^1.8.27" "vue-tsc": "^1.8.27"
} }
}, },
"../../YschTheme/packages/vite-plugin": {
"name": "@yunhai/vite-plugin-theme",
"version": "0.1.0",
"dev": true,
"license": "UNLICENSED",
"devDependencies": {
"tsup": "^8.3.5",
"typescript": "^5.2.2",
"vite": "^5.1.4"
},
"peerDependencies": {
"vite": ">=4.0.0"
}
},
"node_modules/@alova/shared": { "node_modules/@alova/shared": {
"version": "1.3.4", "version": "1.3.4",
"resolved": "https://registry.npmmirror.com/@alova/shared/-/shared-1.3.4.tgz", "resolved": "https://registry.npmmirror.com/@alova/shared/-/shared-1.3.4.tgz",
@@ -90,6 +76,431 @@
"alova": "dist/bin/cli.js" "alova": "dist/bin/cli.js"
} }
}, },
"node_modules/@alova/wormhole/node_modules/@esbuild/aix-ppc64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz",
"integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"aix"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/android-arm": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.25.12.tgz",
"integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/android-arm64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz",
"integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/android-x64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.25.12.tgz",
"integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/darwin-arm64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz",
"integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/darwin-x64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz",
"integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/freebsd-arm64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz",
"integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/freebsd-x64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz",
"integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/linux-arm": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz",
"integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==",
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/linux-arm64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz",
"integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/linux-ia32": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz",
"integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/linux-loong64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz",
"integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==",
"cpu": [
"loong64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/linux-mips64el": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz",
"integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==",
"cpu": [
"mips64el"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/linux-ppc64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz",
"integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==",
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/linux-riscv64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz",
"integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==",
"cpu": [
"riscv64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/linux-s390x": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz",
"integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==",
"cpu": [
"s390x"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/linux-x64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz",
"integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/netbsd-arm64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz",
"integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/netbsd-x64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz",
"integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/openbsd-arm64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz",
"integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/openbsd-x64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz",
"integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/openharmony-arm64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz",
"integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"openharmony"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/sunos-x64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz",
"integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==",
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"sunos"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/win32-arm64": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz",
"integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==",
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/win32-ia32": {
"version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz",
"integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==",
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=18"
}
},
"node_modules/@alova/wormhole/node_modules/@esbuild/win32-x64": { "node_modules/@alova/wormhole/node_modules/@esbuild/win32-x64": {
"version": "0.25.12", "version": "0.25.12",
"resolved": "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", "resolved": "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz",
@@ -2592,7 +3003,7 @@
} }
}, },
"node_modules/@yunhai/vite-plugin-theme": { "node_modules/@yunhai/vite-plugin-theme": {
"resolved": "../../YschTheme/packages/vite-plugin", "resolved": "plugins/vite-plugin-theme",
"link": true "link": true
}, },
"node_modules/acorn": { "node_modules/acorn": {
@@ -10785,6 +11196,358 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/vite/node_modules/@esbuild/aix-ppc64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz",
"integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==",
"cpu": [
"ppc64"
],
"license": "MIT",
"optional": true,
"os": [
"aix"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/android-arm": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz",
"integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/android-arm64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz",
"integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/android-x64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz",
"integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/darwin-arm64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz",
"integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/darwin-x64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz",
"integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/freebsd-arm64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz",
"integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/freebsd-x64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz",
"integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/linux-arm": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz",
"integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/linux-arm64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz",
"integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/linux-ia32": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz",
"integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==",
"cpu": [
"ia32"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/linux-loong64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz",
"integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==",
"cpu": [
"loong64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/linux-mips64el": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz",
"integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==",
"cpu": [
"mips64el"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/linux-ppc64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz",
"integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==",
"cpu": [
"ppc64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/linux-riscv64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz",
"integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==",
"cpu": [
"riscv64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/linux-s390x": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz",
"integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==",
"cpu": [
"s390x"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/linux-x64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz",
"integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/netbsd-x64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz",
"integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/openbsd-x64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz",
"integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/sunos-x64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz",
"integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"sunos"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/win32-arm64": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz",
"integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/@esbuild/win32-ia32": {
"version": "0.21.5",
"resolved": "https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz",
"integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==",
"cpu": [
"ia32"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/vite/node_modules/esbuild": { "node_modules/vite/node_modules/esbuild": {
"version": "0.21.5", "version": "0.21.5",
"resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.21.5.tgz", "resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.21.5.tgz",
@@ -11293,6 +12056,15 @@
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz", "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz",
"integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==", "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==",
"license": "0BSD" "license": "0BSD"
},
"plugins/vite-plugin-theme": {
"name": "@yunhai/vite-plugin-theme",
"version": "0.1.0",
"dev": true,
"license": "UNLICENSED",
"peerDependencies": {
"vite": ">=4.0.0"
}
} }
} }
} }
+1 -1
View File
@@ -40,7 +40,7 @@
"@unocss/preset-rem-to-px": "^66.6.0", "@unocss/preset-rem-to-px": "^66.6.0",
"@unocss/preset-uno": "^66.6.0", "@unocss/preset-uno": "^66.6.0",
"@vitejs/plugin-vue": "^5.0.4", "@vitejs/plugin-vue": "^5.0.4",
"@yunhai/vite-plugin-theme": "file:../../YschTheme/packages/vite-plugin", "@yunhai/vite-plugin-theme": "file:./plugins/vite-plugin-theme",
"fast-glob": "^3.3.2", "fast-glob": "^3.3.2",
"typescript": "^5.2.2", "typescript": "^5.2.2",
"unocss": "^66.6.0", "unocss": "^66.6.0",
+166
View File
@@ -0,0 +1,166 @@
'use strict';
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
DEFAULT_PROXY_TARGET: () => DEFAULT_PROXY_TARGET,
FALLBACK_STYLE: () => FALLBACK_STYLE,
MANIFEST: () => MANIFEST,
RESOLVED_VIRTUAL_ID: () => RESOLVED_VIRTUAL_ID,
VIRTUAL_ID: () => VIRTUAL_ID,
default: () => src_default,
initBootstrap: () => initBootstrap,
isValidStaticBase: () => isValidStaticBase,
loaderSource: () => loaderSource,
yhTheme: () => yhTheme
});
module.exports = __toCommonJS(src_exports);
var DEFAULT_PROXY_TARGET = "http://base.yunhaixingtong.com";
var VIRTUAL_ID = "virtual:yh-theme-loader";
var RESOLVED_VIRTUAL_ID = `\0${VIRTUAL_ID}`;
var MANIFEST = "manifest.json";
var FALLBACK_STYLE = `html:not(.yh-theme-ready) body { opacity: 0; }
html.yh-theme-ready body { opacity: 1; transition: opacity .15s; }`;
function isValidStaticBase(v) {
return v === "" || /^\//.test(v) || /^https?:\/\//.test(v);
}
function loaderSource(staticBase) {
return `// BASE\uFF1A\u6839\u76F8\u5BF9\uFF08\u4E09\u7AEF\u540C\u6E90\uFF09\u3002\u7981\u6B62\u7528 BASE_URL \u4E4B\u7C7B\u7684\u6784\u5EFA\u671F\u76F8\u5BF9\u57FA\u51C6\u2014\u2014
// Notice \u7684 vite base \u662F './'\uFF0C\u4F1A\u89E3\u6790\u6210 /notice/front/static/... \u5BFC\u81F4 404
const BASE = ${JSON.stringify(staticBase)} || (window.__APP_CONFIG__ && window.__APP_CONFIG__.staticHost != null ? window.__APP_CONFIG__.staticHost : '')
const markReady = () => document.documentElement.classList.add('yh-theme-ready')
const markFailed = (f) => {
console.warn(\`[yh-theme] \${f} \u52A0\u8F7D\u5931\u8D25\uFF0C\u964D\u7EA7\u4E3A\u7EC4\u4EF6\u5E93\u9ED8\u8BA4\u89C2\u611F\`)
document.documentElement.classList.add('yh-theme-failed', 'yh-theme-ready')
}
// \u4F18\u5148\u590D\u7528 init \u811A\u672C\u5728 <head> \u91CC\u5DF2\u542F\u52A8\u7684 manifest \u9884\u53D6\uFF08\u542B\u5E26\u7248\u672C preload\uFF09
;(window.__YH_THEME_MANIFEST__ ?? fetch(\`\${BASE}/static/${MANIFEST}\`).then(r => r.json()))
.then((m) => {
let loaded = 0
m.files.forEach((f) => {
const l = document.createElement('link')
l.rel = 'stylesheet'
l.href = \`\${BASE}/static/\${f}?v=\${m.version}\` // \u4E0E init preload \u7684 URL \u4E00\u5B57\u4E0D\u5DEE
l.onload = () => { if (++loaded === m.files.length) markReady() }
l.onerror = () => markFailed(f)
document.head.appendChild(l)
})
setTimeout(markReady, 500) // \u515C\u5E95\uFF1A500ms \u672A load \u5B8C\u4E5F\u653E\u884C
})
.catch(() => markFailed('manifest'))
`;
}
function initBootstrap(staticBase) {
const url = `${staticBase.replace(/\/+$/, "")}/static/js/yh-theme-init.js`;
const setBase = staticBase ? `window.__YH_THEME_STATIC_BASE__=${JSON.stringify(staticBase)};` : "";
return `(function(){${setBase}document.write('<script src="${url}"><\\/script>');})();`;
}
function yhTheme(options = {}) {
const target = options.target ?? "pc";
const staticBase = options.staticBase ?? "";
const proxyTarget = options.proxyTarget ?? DEFAULT_PROXY_TARGET;
if (target !== "pc") {
throw new Error(`[yh-theme] target='${target}' \u7B2C\u4E00\u6CE2\u672A\u5B9E\u73B0\uFF08app \u6CE2\u6B21\u518D\u8865 manifest.app.json \u4E0E app \u4EA7\u7269\uFF09`);
}
if (!isValidStaticBase(staticBase)) {
throw new Error(
`[yh-theme] staticBase \u53EA\u63A5\u53D7 '' / '/xxx' \u6839\u76F8\u5BF9\u524D\u7F00 / 'https?://\u2026'\uFF0C\u6536\u5230 '${staticBase}'\u3002\u4E0D\u8981\u628A vite base \u4F20\u8FDB\u6765\uFF08Notice \u7684 base \u662F './'\uFF0C\u4F1A\u89E3\u6790\u6210 /notice/front/static/... 404\uFF09`
);
}
const entryRe = options.entry ?? /(^|\/)src\/main\.(ts|js)$/;
const proxyFromEnv = () => {
var _a;
const env = (_a = globalThis.process) == null ? void 0 : _a.env;
const v = env == null ? void 0 : env.YH_THEME_PROXY_TARGET;
return v && v.trim() ? v.trim() : void 0;
};
return {
name: "@yunhai/vite-plugin-theme",
/**
* proxy 在 config 钩子里合并:Vite 的 proxy 中间件在 configureServer 之前就已建立,
* 到 configureServer 里再改 server.config.server.proxy 不会生效(B4 的语义在这里落地)。
*/
config(userConfig) {
var _a;
const url = proxyFromEnv() ?? proxyTarget;
const existing = ((_a = userConfig.server) == null ? void 0 : _a.proxy) ?? {};
if (existing["/static"]) return {};
const patch = {
proxy: {
...existing,
"/static": { target: url, changeOrigin: true }
}
};
if (!proxyFromEnv() && url !== DEFAULT_PROXY_TARGET) {
patch.proxy["/static"] = {
target: url,
changeOrigin: true,
headers: { Host: DEFAULT_PROXY_TARGET.replace(/^https?:\/\//, "") }
};
}
return { server: patch };
},
resolveId(id) {
return id === VIRTUAL_ID ? RESOLVED_VIRTUAL_ID : null;
},
load(id) {
return id === RESOLVED_VIRTUAL_ID ? loaderSource(staticBase) : null;
},
transform(code, id) {
const cleanId = id.split("?")[0].replace(/\\/g, "/");
if (!entryRe.test(cleanId)) return null;
if (code.includes(VIRTUAL_ID)) return null;
return { code: `${code}
import "${VIRTUAL_ID}";
`, map: null };
},
transformIndexHtml: {
order: "post",
handler() {
return [
{ tag: "style", children: FALLBACK_STYLE, injectTo: "head" },
{ tag: "script", children: initBootstrap(staticBase), injectTo: "head" }
];
}
},
configureServer(server) {
var _a;
const proxy = ((_a = server.config.server) == null ? void 0 : _a.proxy) ?? {};
const target0 = proxy["/static"];
server.config.logger.info(
`[yh-theme] dev /static \u2192 ${(target0 == null ? void 0 : target0.target) ?? "(\u672A\u6302\uFF1A\u5E94\u7528\u4FA7\u5DF2\u81EA\u5E26\u540C\u540D proxy\uFF1F)"}${proxyFromEnv() ? `\uFF08YH_THEME_PROXY_TARGET=${proxyFromEnv()}\uFF09` : ""}`
);
}
};
}
var src_default = yhTheme;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DEFAULT_PROXY_TARGET,
FALLBACK_STYLE,
MANIFEST,
RESOLVED_VIRTUAL_ID,
VIRTUAL_ID,
initBootstrap,
isValidStaticBase,
loaderSource,
yhTheme
});
+44
View File
@@ -0,0 +1,44 @@
import { Plugin } from 'vite';
/**
* @yunhai/vite-plugin-theme — 云海管理端远程主题接入插件。
*
* 接入面收敛成一行:plugins: [vue(), yhTheme()]。插件负责四件事:
* 1. transformIndexHtml:<head> 内注入 yh-theme-init.js(在 env-config bootstrap 之后)+ 首帧兜底 inline style;
* 刻意不静态注入 preload——构建期 URL 没有 ?v=,与 loader 运行时版本化 URL 永不匹配(缓存键含 query)。
* 2. virtual:yh-theme-loader:入口末位运行时 append <link>,保证远程 CSS 排在 viewuiplus.css 之后(dev/build 同构)。
* 3. transform:自动在入口末位 import 该虚拟模块,应用侧不用手改 main.ts。
* 4. /static dev proxy:本地联调不必装内网 DNS;环境变量 YH_THEME_PROXY_TARGET 可指向模拟通道。
*/
interface YhThemeOptions {
/** 产物档:pc 为第一波实现,app 占位 */
target?: "pc" | "app";
/** 静态通道前缀:'' 同源根相对(默认)| '/xxx' | 'http(s)://…'。禁止传 vite base(如 './') */
staticBase?: string;
/** dev /static proxy 目标;环境变量 YH_THEME_PROXY_TARGET 优先 */
proxyTarget?: string;
/** 入口匹配(相对路径正则),默认 src/main.(ts|js) */
entry?: RegExp;
}
declare const DEFAULT_PROXY_TARGET = "http://base.yunhaixingtong.com";
declare const VIRTUAL_ID = "virtual:yh-theme-loader";
declare const RESOLVED_VIRTUAL_ID = "\0virtual:yh-theme-loader";
declare const MANIFEST = "manifest.json";
declare const FALLBACK_STYLE = "html:not(.yh-theme-ready) body { opacity: 0; }\nhtml.yh-theme-ready body { opacity: 1; transition: opacity .15s; }";
/** staticBase 只接受根相对绝对前缀或完整 URL:vite base(Notice 是 './')会让 /static 解析成 /notice/front/static/… */
declare function isValidStaticBase(v: string): boolean;
/**
* loader 运行时实现 —— 基准为《第一波实施清单》§B3 代码块,语义一字不改。
* 复用 init 已启动的 manifest 预取;URL 与 init 的带版本 preload 一字不差;500ms 兜底;失败挂双类。
*/
declare function loaderSource(staticBase: string): string;
/**
* init 用 document.write 挂:直接写 <script src="/static/…"> 会让 vite:build-html 把这条绝对路径
* 当本仓资源解析(构建报 "Failed to resolve"),而远程通道的文件根本不在应用构建图里。
* document.write 在 <head> 内是 parser-blocking 的,恰好保住 init 必须先于首帧执行的语义。
*/
declare function initBootstrap(staticBase: string): string;
declare function yhTheme(options?: YhThemeOptions): Plugin;
export { DEFAULT_PROXY_TARGET, FALLBACK_STYLE, MANIFEST, RESOLVED_VIRTUAL_ID, VIRTUAL_ID, type YhThemeOptions, yhTheme as default, initBootstrap, isValidStaticBase, loaderSource, yhTheme };
+44
View File
@@ -0,0 +1,44 @@
import { Plugin } from 'vite';
/**
* @yunhai/vite-plugin-theme — 云海管理端远程主题接入插件。
*
* 接入面收敛成一行:plugins: [vue(), yhTheme()]。插件负责四件事:
* 1. transformIndexHtml:<head> 内注入 yh-theme-init.js(在 env-config bootstrap 之后)+ 首帧兜底 inline style;
* 刻意不静态注入 preload——构建期 URL 没有 ?v=,与 loader 运行时版本化 URL 永不匹配(缓存键含 query)。
* 2. virtual:yh-theme-loader:入口末位运行时 append <link>,保证远程 CSS 排在 viewuiplus.css 之后(dev/build 同构)。
* 3. transform:自动在入口末位 import 该虚拟模块,应用侧不用手改 main.ts。
* 4. /static dev proxy:本地联调不必装内网 DNS;环境变量 YH_THEME_PROXY_TARGET 可指向模拟通道。
*/
interface YhThemeOptions {
/** 产物档:pc 为第一波实现,app 占位 */
target?: "pc" | "app";
/** 静态通道前缀:'' 同源根相对(默认)| '/xxx' | 'http(s)://…'。禁止传 vite base(如 './') */
staticBase?: string;
/** dev /static proxy 目标;环境变量 YH_THEME_PROXY_TARGET 优先 */
proxyTarget?: string;
/** 入口匹配(相对路径正则),默认 src/main.(ts|js) */
entry?: RegExp;
}
declare const DEFAULT_PROXY_TARGET = "http://base.yunhaixingtong.com";
declare const VIRTUAL_ID = "virtual:yh-theme-loader";
declare const RESOLVED_VIRTUAL_ID = "\0virtual:yh-theme-loader";
declare const MANIFEST = "manifest.json";
declare const FALLBACK_STYLE = "html:not(.yh-theme-ready) body { opacity: 0; }\nhtml.yh-theme-ready body { opacity: 1; transition: opacity .15s; }";
/** staticBase 只接受根相对绝对前缀或完整 URL:vite base(Notice 是 './')会让 /static 解析成 /notice/front/static/… */
declare function isValidStaticBase(v: string): boolean;
/**
* loader 运行时实现 —— 基准为《第一波实施清单》§B3 代码块,语义一字不改。
* 复用 init 已启动的 manifest 预取;URL 与 init 的带版本 preload 一字不差;500ms 兜底;失败挂双类。
*/
declare function loaderSource(staticBase: string): string;
/**
* init 用 document.write 挂:直接写 <script src="/static/…"> 会让 vite:build-html 把这条绝对路径
* 当本仓资源解析(构建报 "Failed to resolve"),而远程通道的文件根本不在应用构建图里。
* document.write 在 <head> 内是 parser-blocking 的,恰好保住 init 必须先于首帧执行的语义。
*/
declare function initBootstrap(staticBase: string): string;
declare function yhTheme(options?: YhThemeOptions): Plugin;
export { DEFAULT_PROXY_TARGET, FALLBACK_STYLE, MANIFEST, RESOLVED_VIRTUAL_ID, VIRTUAL_ID, type YhThemeOptions, yhTheme as default, initBootstrap, isValidStaticBase, loaderSource, yhTheme };
+132
View File
@@ -0,0 +1,132 @@
// src/index.ts
var DEFAULT_PROXY_TARGET = "http://base.yunhaixingtong.com";
var VIRTUAL_ID = "virtual:yh-theme-loader";
var RESOLVED_VIRTUAL_ID = `\0${VIRTUAL_ID}`;
var MANIFEST = "manifest.json";
var FALLBACK_STYLE = `html:not(.yh-theme-ready) body { opacity: 0; }
html.yh-theme-ready body { opacity: 1; transition: opacity .15s; }`;
function isValidStaticBase(v) {
return v === "" || /^\//.test(v) || /^https?:\/\//.test(v);
}
function loaderSource(staticBase) {
return `// BASE\uFF1A\u6839\u76F8\u5BF9\uFF08\u4E09\u7AEF\u540C\u6E90\uFF09\u3002\u7981\u6B62\u7528 BASE_URL \u4E4B\u7C7B\u7684\u6784\u5EFA\u671F\u76F8\u5BF9\u57FA\u51C6\u2014\u2014
// Notice \u7684 vite base \u662F './'\uFF0C\u4F1A\u89E3\u6790\u6210 /notice/front/static/... \u5BFC\u81F4 404
const BASE = ${JSON.stringify(staticBase)} || (window.__APP_CONFIG__ && window.__APP_CONFIG__.staticHost != null ? window.__APP_CONFIG__.staticHost : '')
const markReady = () => document.documentElement.classList.add('yh-theme-ready')
const markFailed = (f) => {
console.warn(\`[yh-theme] \${f} \u52A0\u8F7D\u5931\u8D25\uFF0C\u964D\u7EA7\u4E3A\u7EC4\u4EF6\u5E93\u9ED8\u8BA4\u89C2\u611F\`)
document.documentElement.classList.add('yh-theme-failed', 'yh-theme-ready')
}
// \u4F18\u5148\u590D\u7528 init \u811A\u672C\u5728 <head> \u91CC\u5DF2\u542F\u52A8\u7684 manifest \u9884\u53D6\uFF08\u542B\u5E26\u7248\u672C preload\uFF09
;(window.__YH_THEME_MANIFEST__ ?? fetch(\`\${BASE}/static/${MANIFEST}\`).then(r => r.json()))
.then((m) => {
let loaded = 0
m.files.forEach((f) => {
const l = document.createElement('link')
l.rel = 'stylesheet'
l.href = \`\${BASE}/static/\${f}?v=\${m.version}\` // \u4E0E init preload \u7684 URL \u4E00\u5B57\u4E0D\u5DEE
l.onload = () => { if (++loaded === m.files.length) markReady() }
l.onerror = () => markFailed(f)
document.head.appendChild(l)
})
setTimeout(markReady, 500) // \u515C\u5E95\uFF1A500ms \u672A load \u5B8C\u4E5F\u653E\u884C
})
.catch(() => markFailed('manifest'))
`;
}
function initBootstrap(staticBase) {
const url = `${staticBase.replace(/\/+$/, "")}/static/js/yh-theme-init.js`;
const setBase = staticBase ? `window.__YH_THEME_STATIC_BASE__=${JSON.stringify(staticBase)};` : "";
return `(function(){${setBase}document.write('<script src="${url}"><\\/script>');})();`;
}
function yhTheme(options = {}) {
const target = options.target ?? "pc";
const staticBase = options.staticBase ?? "";
const proxyTarget = options.proxyTarget ?? DEFAULT_PROXY_TARGET;
if (target !== "pc") {
throw new Error(`[yh-theme] target='${target}' \u7B2C\u4E00\u6CE2\u672A\u5B9E\u73B0\uFF08app \u6CE2\u6B21\u518D\u8865 manifest.app.json \u4E0E app \u4EA7\u7269\uFF09`);
}
if (!isValidStaticBase(staticBase)) {
throw new Error(
`[yh-theme] staticBase \u53EA\u63A5\u53D7 '' / '/xxx' \u6839\u76F8\u5BF9\u524D\u7F00 / 'https?://\u2026'\uFF0C\u6536\u5230 '${staticBase}'\u3002\u4E0D\u8981\u628A vite base \u4F20\u8FDB\u6765\uFF08Notice \u7684 base \u662F './'\uFF0C\u4F1A\u89E3\u6790\u6210 /notice/front/static/... 404\uFF09`
);
}
const entryRe = options.entry ?? /(^|\/)src\/main\.(ts|js)$/;
const proxyFromEnv = () => {
var _a;
const env = (_a = globalThis.process) == null ? void 0 : _a.env;
const v = env == null ? void 0 : env.YH_THEME_PROXY_TARGET;
return v && v.trim() ? v.trim() : void 0;
};
return {
name: "@yunhai/vite-plugin-theme",
/**
* proxy 在 config 钩子里合并:Vite 的 proxy 中间件在 configureServer 之前就已建立,
* 到 configureServer 里再改 server.config.server.proxy 不会生效(B4 的语义在这里落地)。
*/
config(userConfig) {
var _a;
const url = proxyFromEnv() ?? proxyTarget;
const existing = ((_a = userConfig.server) == null ? void 0 : _a.proxy) ?? {};
if (existing["/static"]) return {};
const patch = {
proxy: {
...existing,
"/static": { target: url, changeOrigin: true }
}
};
if (!proxyFromEnv() && url !== DEFAULT_PROXY_TARGET) {
patch.proxy["/static"] = {
target: url,
changeOrigin: true,
headers: { Host: DEFAULT_PROXY_TARGET.replace(/^https?:\/\//, "") }
};
}
return { server: patch };
},
resolveId(id) {
return id === VIRTUAL_ID ? RESOLVED_VIRTUAL_ID : null;
},
load(id) {
return id === RESOLVED_VIRTUAL_ID ? loaderSource(staticBase) : null;
},
transform(code, id) {
const cleanId = id.split("?")[0].replace(/\\/g, "/");
if (!entryRe.test(cleanId)) return null;
if (code.includes(VIRTUAL_ID)) return null;
return { code: `${code}
import "${VIRTUAL_ID}";
`, map: null };
},
transformIndexHtml: {
order: "post",
handler() {
return [
{ tag: "style", children: FALLBACK_STYLE, injectTo: "head" },
{ tag: "script", children: initBootstrap(staticBase), injectTo: "head" }
];
}
},
configureServer(server) {
var _a;
const proxy = ((_a = server.config.server) == null ? void 0 : _a.proxy) ?? {};
const target0 = proxy["/static"];
server.config.logger.info(
`[yh-theme] dev /static \u2192 ${(target0 == null ? void 0 : target0.target) ?? "(\u672A\u6302\uFF1A\u5E94\u7528\u4FA7\u5DF2\u81EA\u5E26\u540C\u540D proxy\uFF1F)"}${proxyFromEnv() ? `\uFF08YH_THEME_PROXY_TARGET=${proxyFromEnv()}\uFF09` : ""}`
);
}
};
}
var src_default = yhTheme;
export {
DEFAULT_PROXY_TARGET,
FALLBACK_STYLE,
MANIFEST,
RESOLVED_VIRTUAL_ID,
VIRTUAL_ID,
src_default as default,
initBootstrap,
isValidStaticBase,
loaderSource,
yhTheme
};
+34
View File
@@ -0,0 +1,34 @@
{
"name": "@yunhai/vite-plugin-theme",
"version": "0.1.0",
"description": "云海管理端远程主题接入插件:注入 yh-theme-init / 首帧兜底样式 / virtual:yh-theme-loader / dev /static proxy",
"_vendored": "临时 vendored 自 YschTheme/packages/vite-plugin 的构建产物(lib/,原 dist 改名以规避本仓 .gitignore 的 dist 规则)。已剥离 devDependencies/scripts(消费端无需重建)。Nexus 建好 npm 仓后改回按版本号消费并删除本目录。",
"type": "module",
"main": "./lib/index.cjs",
"module": "./lib/index.js",
"types": "./lib/index.d.ts",
"exports": {
".": {
"import": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"require": {
"types": "./lib/index.d.cts",
"default": "./lib/index.cjs"
}
}
},
"files": [
"lib"
],
"keywords": [
"vite-plugin",
"yunhai",
"theme"
],
"license": "UNLICENSED",
"peerDependencies": {
"vite": ">=4.0.0"
}
}