@lark-apaas/coding-template-react-standard-webapp 0.1.1 → 0.1.2-beta.0
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/package.json +1 -1
- package/template/vite.config.ts +20 -1
package/package.json
CHANGED
package/template/vite.config.ts
CHANGED
|
@@ -58,6 +58,25 @@ function miaodaOutputPlugin(): Plugin {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
// 本地开发自描述端点(协议 v0.4):GET /spark.json 原样返回项目根声明文件,
|
|
62
|
+
// 供消费方(豆包客户端/Agent)识别妙搭托管协议应用;仅 dev server,线上不暴露
|
|
63
|
+
function sparkJsonPlugin(): Plugin {
|
|
64
|
+
return {
|
|
65
|
+
name: 'spark-json-endpoint',
|
|
66
|
+
apply: 'serve',
|
|
67
|
+
configureServer(server) {
|
|
68
|
+
server.middlewares.use('/spark.json', (_req, res) => {
|
|
69
|
+
res.setHeader('Content-Type', 'application/json');
|
|
70
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
71
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
72
|
+
res.end(
|
|
73
|
+
fs.readFileSync(path.resolve(import.meta.dirname, 'spark.json')),
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
61
80
|
// 收集 <Route path="..."> 声明的路由;index 路由计为 "/",通配 "*" 不进枚举
|
|
62
81
|
function collectRoutePaths(srcDir: string): string[] {
|
|
63
82
|
const paths = new Set<string>(['/']);
|
|
@@ -81,7 +100,7 @@ function collectRoutePaths(srcDir: string): string[] {
|
|
|
81
100
|
}
|
|
82
101
|
|
|
83
102
|
export default defineConfig(({ command }) => ({
|
|
84
|
-
plugins: [react(), tailwindcss(), miaodaOutputPlugin()],
|
|
103
|
+
plugins: [react(), tailwindcss(), miaodaOutputPlugin(), sparkJsonPlugin()],
|
|
85
104
|
// 生产构建:JS/CSS 引用带 CDN 前缀(无 CDN 时退回 base path);dev 恒为 /
|
|
86
105
|
base: command === 'build' ? cdnPrefix || basePath : '/',
|
|
87
106
|
define: {
|