@proteus-vue/create-proteus 0.2.0 → 0.2.1-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/LICENSE ADDED
@@ -0,0 +1,218 @@
1
+ Proteus(普罗透斯)Vue 跨端编译框架
2
+ Copyright (c) 2026 Proteus Contributors
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+
16
+ ═══════════════════════════════════════════════════════════════════════════════
17
+
18
+ Apache License
19
+ Version 2.0, January 2004
20
+ http://www.apache.org/licenses/
21
+
22
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
23
+
24
+ 1. Definitions.
25
+
26
+ "License" shall mean the terms and conditions for use, reproduction,
27
+ and distribution as defined by Sections 1 through 9 of this document.
28
+
29
+ "Licensor" shall mean the copyright owner or entity authorized by
30
+ the copyright owner that is granting the License.
31
+
32
+ "Legal Entity" shall mean the union of the acting entity and all
33
+ other entities that control, are controlled by, or are under common
34
+ control with that entity. For the purposes of this definition,
35
+ "control" means (i) the power, direct or indirect, to cause the
36
+ direction or management of such entity, whether by contract or
37
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
38
+ outstanding shares, or (iii) beneficial ownership of such entity.
39
+
40
+ "You" (or "Your") shall mean an individual or Legal Entity
41
+ exercising permissions granted by this License.
42
+
43
+ "Source" form shall mean the preferred form for making modifications,
44
+ including but not limited to software source code, documentation
45
+ source, and configuration files.
46
+
47
+ "Object" form shall mean any form resulting from mechanical
48
+ transformation or translation of a Source form, including but
49
+ not limited to compiled object code, generated documentation,
50
+ and conversions to other media types.
51
+
52
+ "Work" shall mean the work of authorship, whether in Source or
53
+ Object form, made available under the License, as indicated by a
54
+ copyright notice that is included in or attached to the work
55
+ (an example is provided in the Appendix below).
56
+
57
+ "Derivative Works" shall mean any work, whether in Source or Object
58
+ form, that is based on (or derived from) the Work and for which the
59
+ editorial revisions, annotations, elaborations, or other modifications
60
+ represent, as a whole, an original work of authorship. For the purposes
61
+ of this License, Derivative Works shall not include works that remain
62
+ separable from, or merely link (or bind by name) to the interfaces of,
63
+ the Work and Derivative Works thereof.
64
+
65
+ "Contribution" shall mean any work of authorship, including
66
+ the original version of the Work and any modifications or additions
67
+ to that Work or Derivative Works thereof, that is intentionally
68
+ submitted to Licensor for inclusion in the Work by the copyright owner
69
+ or by an individual or Legal Entity authorized to submit on behalf of
70
+ the copyright owner. For the purposes of this definition, "submitted"
71
+ means any form of electronic, verbal, or written communication sent
72
+ to the Licensor or its representatives, including but not limited to
73
+ communication on electronic mailing lists, source code control systems,
74
+ and issue tracking systems that are managed by, or on behalf of, the
75
+ Licensor for the purpose of discussing and improving the Work, but
76
+ excluding communication that is conspicuously marked or otherwise
77
+ designated in writing by the copyright owner as "Not a Contribution."
78
+
79
+ "Contributor" shall mean Licensor and any individual or Legal Entity
80
+ on behalf of whom a Contribution has been received by Licensor and
81
+ subsequently incorporated within the Work.
82
+
83
+ 2. Grant of Copyright License. Subject to the terms and conditions of
84
+ this License, each Contributor hereby grants to You a perpetual,
85
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
86
+ copyright license to reproduce, prepare Derivative Works of,
87
+ publicly display, publicly perform, sublicense, and distribute the
88
+ Work and such Derivative Works in Source or Object form.
89
+
90
+ 3. Grant of Patent License. Subject to the terms and conditions of
91
+ this License, each Contributor hereby grants to You a perpetual,
92
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
93
+ (except as stated in this section) patent license to make, have made,
94
+ use, offer to sell, sell, import, and otherwise transfer the Work,
95
+ where such license applies only to those patent claims licensable
96
+ by such Contributor that are necessarily infringed by their
97
+ Contribution(s) alone or by combination of their Contribution(s)
98
+ with the Work to which such Contribution(s) was submitted. If You
99
+ institute patent litigation against any entity (including a
100
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
101
+ or a Contribution incorporated within the Work constitutes direct
102
+ or contributory patent infringement, then any patent licenses
103
+ granted to You under this License for that Work shall terminate
104
+ as of the date such litigation is filed.
105
+
106
+ 4. Redistribution. You may reproduce and distribute copies of the
107
+ Work or Derivative Works thereof in any medium, with or without
108
+ modifications, and in Source or Object form, provided that You
109
+ meet the following conditions:
110
+
111
+ (a) You must give any other recipients of the Work or
112
+ Derivative Works a copy of this License; and
113
+
114
+ (b) You must cause any modified files to carry prominent notices
115
+ stating that You changed the files; and
116
+
117
+ (c) You must retain, in the Source form of any Derivative Works
118
+ that You distribute, all copyright, patent, trademark, and
119
+ attribution notices from the Source form of the Work,
120
+ excluding those notices that do not pertain to any part of
121
+ the Derivative Works; and
122
+
123
+ (d) If the Work includes a "NOTICE" text file as part of its
124
+ distribution, then any Derivative Works that You distribute must
125
+ include a readable copy of the attribution notices contained
126
+ within such NOTICE file, excluding those notices that do not
127
+ pertain to any part of the Derivative Works, in at least one
128
+ of the following places: within a NOTICE text file distributed
129
+ as part of the Derivative Works; within the Source form or
130
+ documentation, if provided along with the Derivative Works; or,
131
+ within a display generated by the Derivative Works, if and
132
+ wherever such third-party notices normally appear. The contents
133
+ of the NOTICE file are for informational purposes only and
134
+ do not modify the License. You may add Your own attribution
135
+ notices within Derivative Works that You distribute, alongside
136
+ or as an addendum to the NOTICE text from the Work, provided
137
+ that such additional attribution notices cannot be construed
138
+ as modifying the License.
139
+
140
+ You may add Your own copyright statement to Your modifications and
141
+ may provide additional or different license terms and conditions
142
+ for use, reproduction, or distribution of Your modifications, or
143
+ for any such Derivative Works as a whole, provided Your use,
144
+ reproduction, and distribution of the Work otherwise complies with
145
+ the conditions stated in this License.
146
+
147
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
148
+ any Contribution intentionally submitted for inclusion in the Work
149
+ by You to the Licensor shall be under the terms and conditions of
150
+ this License, without any additional terms or conditions.
151
+ Notwithstanding the above, nothing herein shall supersede or modify
152
+ the terms of any separate license agreement you may have executed
153
+ with Licensor regarding such Contributions.
154
+
155
+ 6. Trademarks. This License does not grant permission to use the trade
156
+ names, trademarks, service marks, or product names of the Licensor,
157
+ except as required for reasonable and customary use in describing the
158
+ origin of the Work and reproducing the content of the NOTICE file.
159
+
160
+ 7. Disclaimer of Warranty. Unless required by applicable law or
161
+ agreed to in writing, Licensor provides the Work (and each
162
+ Contributor provides its Contributions) on an "AS IS" BASIS,
163
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
164
+ implied, including, without limitation, any warranties or conditions
165
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
166
+ PARTICULAR PURPOSE. You are solely responsible for determining the
167
+ appropriateness of using or redistributing the Work and assume any
168
+ risks associated with Your exercise of permissions under this License.
169
+
170
+ 8. Limitation of Liability. In no event and under no legal theory,
171
+ whether in tort (including negligence), contract, or otherwise,
172
+ unless required by applicable law (such as deliberate and grossly
173
+ negligent acts) or agreed to in writing, shall any Contributor be
174
+ liable to You for damages, including any direct, indirect, special,
175
+ incidental, or consequential damages of any character arising as a
176
+ result of this License or out of the use or inability to use the
177
+ Work (including but not limited to damages for loss of goodwill,
178
+ work stoppage, computer failure or malfunction, or any and all
179
+ other commercial damages or losses), even if such Contributor
180
+ has been advised of the possibility of such damages.
181
+
182
+ 9. Accepting Warranty or Additional Liability. While redistributing
183
+ the Work or Derivative Works thereof, You may choose to offer,
184
+ and charge a fee for, acceptance of support, warranty, indemnity,
185
+ or other liability obligations and/or rights consistent with this
186
+ License. However, in accepting such obligations, You may act only
187
+ on Your own behalf and on Your sole responsibility, not on behalf
188
+ of any other Contributor, and only if You agree to indemnify,
189
+ defend, and hold each Contributor harmless for any liability
190
+ incurred by, or claims asserted against, such Contributor by reason
191
+ of your accepting any such warranty or additional liability.
192
+
193
+ END OF TERMS AND CONDITIONS
194
+
195
+ APPENDIX: How to apply the Apache License to your work.
196
+
197
+ To apply the Apache License to your work, attach the following
198
+ boilerplate notice, with the fields enclosed by brackets "[]"
199
+ replaced with your own identifying information. (Don't include
200
+ the brackets!) The text should be enclosed in the appropriate
201
+ comment syntax for the file format. We also recommend that a
202
+ file or class name and description of purpose be included on the
203
+ same "printed page" as the copyright notice for easier
204
+ identification within third-party archives.
205
+
206
+ Copyright [yyyy] [name of copyright owner]
207
+
208
+ Licensed under the Apache License, Version 2.0 (the "License");
209
+ you may not use this file except in compliance with the License.
210
+ You may obtain a copy of the License at
211
+
212
+ http://www.apache.org/licenses/LICENSE-2.0
213
+
214
+ Unless required by applicable law or agreed to in writing, software
215
+ distributed under the License is distributed on an "AS IS" BASIS,
216
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
217
+ See the License for the specific language governing permissions and
218
+ limitations under the License.
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ var NEXT_STEPS = (name) => `\u2705 \u5DF2\u751F\u6210\u5DE5\u7A0B\uFF1A${name}
8
8
 
9
9
  \u4E0B\u4E00\u6B65\uFF1A
10
10
  cd ${name}
11
- npm install # \u5B89\u88C5\u4F9D\u8D56\uFF08@proteus-vue/compiler \u53D1\u5E03\u540E\u53EF\u6B63\u5E38\u5B89\u88C5\uFF1B\u672A\u53D1\u5E03\u65F6\u7528\u4ED3\u5E93 workspace \u6216 npm link\uFF09
11
+ npm install # \u5B89\u88C5\u4F9D\u8D56\uFF08@proteus-vue/* \u5DF2\u53D1\u5E03 npm\uFF0C\u76F4\u63A5\u5B89\u88C5\uFF09
12
12
  npm run dev:web # Web \u7AEF\uFF08\u6D4F\u89C8\u5668\u6253\u5F00 Vite \u63D0\u793A\u5730\u5740\uFF09
13
13
  npm run build:mp # \u5C0F\u7A0B\u5E8F\u7AEF\uFF08\u5FAE\u4FE1\u5F00\u53D1\u8005\u5DE5\u5177\u5BFC\u5165 dist/mp-weixin\uFF0C\u9700\u66FF\u6362 proteus.config.ts \u7684 appid\uFF09
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proteus-vue/create-proteus",
3
- "version": "0.2.0",
3
+ "version": "0.2.1-beta.0",
4
4
  "description": "Proteus 脚手架:npm create @proteus-vue/proteus my-app —— 一键生成 Web + 微信小程序(Skyline)双端工程",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -18,4 +18,4 @@
18
18
  "scripts": {
19
19
  "build": "tsc -p tsconfig.build.json --emitDeclarationOnly && esbuild src/index.ts --bundle --format=esm --platform=node --outfile=dist/index.js --banner:js=\"#!/usr/bin/env node\""
20
20
  }
21
- }
21
+ }
@@ -2,7 +2,8 @@
2
2
  <html lang="zh-CN">
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
6
+ <!-- ★应用标题唯一事实源 = app.config.ts app.name(决策 #212);此处静态 title 仅首屏兜底,App.vue onMounted 运行时覆盖 -->
6
7
  <title>Proteus</title>
7
8
  </head>
8
9
  <body>
@@ -5,12 +5,12 @@
5
5
  "type": "module",
6
6
  "description": "Proteus 应用:一份标准 Vue 源码 → Web + 微信小程序(Skyline)",
7
7
  "scripts": {
8
- "dev:web": "vite --mode web",
9
- "build:web": "vue-tsc --noEmit && vite build --mode web",
10
- "dev:mp": "tsx scripts/gen-routes.ts && vite --mode mp-weixin",
11
- "build:mp": "tsx scripts/gen-routes.ts && vue-tsc --noEmit && vite build --mode mp-weixin",
12
- "debug:mp": "PROTEUS_DEBUG=1 npm run build:mp",
13
- "proteus": "npx proteus"
8
+ "dev:web": "proteus dev --target web",
9
+ "build:web": "proteus build --target web",
10
+ "dev:mp": "proteus dev --target skyline",
11
+ "build:mp": "proteus build --target skyline",
12
+ "debug:mp": "PROTEUS_DEBUG=1 proteus build --target skyline",
13
+ "proteus": "proteus"
14
14
  },
15
15
  "dependencies": {
16
16
  "@proteus-vue/router": "^0.2.0-beta.0",
@@ -19,6 +19,7 @@
19
19
  "vue": "^3.4.0"
20
20
  },
21
21
  "devDependencies": {
22
+ "@proteus-vue/cli": "^0.2.1-beta.0",
22
23
  "@proteus-vue/compiler": "^0.3.0-beta.0",
23
24
  "@proteus-vue/plugin-vite": "^0.2.0-beta.0",
24
25
  "@types/node": "^20.0.0",
@@ -26,6 +27,7 @@
26
27
  "tsx": "^4.0.0",
27
28
  "typescript": "^5.4.0",
28
29
  "vite": "^5.0.0",
29
- "vue-tsc": "^2.0.0"
30
+ "vue-tsc": "^2.0.0",
31
+ "@proteus-vue/devtools-runtime": "^0.1.0"
30
32
  }
31
- }
33
+ }
@@ -1,4 +1,4 @@
1
- // proteus.config.ts —— Proteus 框架统一配置(拆包步骤 7:类型契约来自 @proteus-vue/plugin-vite npm 包)
1
+ // proteus.config.ts —— Proteus 统一配置(★#418:唯一配置文件——vite 配置由框架组装,不再有 vite.config.ts)
2
2
  import type { ProteusConfig } from '@proteus-vue/plugin-vite'
3
3
 
4
4
  const config: ProteusConfig = {
@@ -6,15 +6,21 @@ const config: ProteusConfig = {
6
6
  skyline: true,
7
7
  appid: 'wx0000000000', // 替换为真实 AppID
8
8
  pagesDir: 'src/pages',
9
- routesOutput: 'src/router/auto-routes.ts',
10
- customRoute: {
11
- registerPresets: true,
12
- // 内置预设 builders(随 @proteus-vue/router 包发布源码,插件读取后内联进 app.js 注册)
13
- builders: {
14
- halfScreen: 'node_modules/@proteus-vue/router/src/presets/halfScreen.ts',
15
- slideUp: 'node_modules/@proteus-vue/router/src/presets/slideUp.ts',
16
- scaleDown: 'node_modules/@proteus-vue/router/src/presets/scaleDown.ts',
9
+ // ★#492 项目级路由管理:路由相关配置统一在 router 段(结构 + tabBar + meta)
10
+ router: {
11
+ // 路由表产物路径(编译期 gen-routes 生成)
12
+ routesOutput: 'src/router/auto-routes.ts',
13
+ // wx.router 自定义路由:内置预设 builders(随 @proteus-vue/router 包发布源码,插件读取后内联进 app.js 注册)
14
+ customRoute: {
15
+ registerPresets: true,
16
+ builders: {
17
+ halfScreen: 'node_modules/@proteus-vue/router/src/presets/halfScreen.ts',
18
+ slideUp: 'node_modules/@proteus-vue/router/src/presets/slideUp.ts',
19
+ scaleDown: 'node_modules/@proteus-vue/router/src/presets/scaleDown.ts',
20
+ },
17
21
  },
22
+ // 集中式 meta(可选):精确路径 > 目录前缀 > 默认
23
+ // meta: { 'index': { title: '首页', isTab: true } },
18
24
  },
19
25
  // ★底线循环 ①③:规则覆盖(改这里立即改变编译行为)
20
26
  rules: {
@@ -30,6 +36,12 @@ const config: ProteusConfig = {
30
36
  px2rpx: true,
31
37
  rpxRatio: 2,
32
38
  },
39
+ // vite 透传(可选):完全兼容 vite 的字段——plugins / server / resolve / build 等按需追加。
40
+ // 例:server: { port: 5173 }, plugins: [myVitePlugin()]
41
+ // (函数形态:vite: ({ command, mode }) => ({ ... });省略则全用框架默认组装)
42
+ // vite: {
43
+ // server: { port: 5173 },
44
+ // },
33
45
  }
34
46
 
35
47
  export default config
@@ -89,7 +89,7 @@ const view = computed<Component | null>(() => {
89
89
  </div>
90
90
  </template>
91
91
 
92
- <style>
92
+ <style scoped>
93
93
  /* 层叠容器:所有 routeType 转场时新旧页同屏绝对定位重叠 */
94
94
  .router-view {
95
95
  position: relative;
@@ -132,12 +132,18 @@ const view = computed<Component | null>(() => {
132
132
  }
133
133
 
134
134
  /* 页面"纸片"基础样式:白色背景 + 撑满视口 + 恒在遮罩(z:1)之上(z:2)
135
- 层叠转场时旧页被 leave 规则降为 z:0 暴露在遮罩下;停留页始终盖住遮罩 */
135
+ 层叠转场时旧页被 leave 规则降为 z:0 暴露在遮罩下;停留页始终盖住遮罩
136
+ ★暗黑模式:页面底色随系统(微信小程序暗黑模式下页面深底——Web 模拟层对齐) */
136
137
  .page {
137
138
  background: #fff;
138
139
  min-height: 100vh;
139
140
  z-index: 2;
140
141
  }
142
+ @media (prefers-color-scheme: dark) {
143
+ .page {
144
+ background: #111111; /* 官方暗黑页面底色 rgb(17,17,17) */
145
+ }
146
+ }
141
147
 
142
148
  /* 默认:淡入淡出 */
143
149
  .fade-enter-active,
@@ -3,8 +3,10 @@
3
3
  // 应用开发者视角:只需这一行单例;换应用换路由表,框架零改动
4
4
  import { createRouter } from '@proteus-vue/router'
5
5
  import { routes } from './auto-routes'
6
+ // ★devtools 打通:路由事件 → TraceBus(惰性单例与 installProteusDevtools 同源;bus 门控生产零开销)
7
+ import { getProteusTraceBus } from '@proteus-vue/devtools-runtime'
6
8
 
7
- export const router = createRouter(routes)
9
+ export const router = createRouter(routes, { traceBus: getProteusTraceBus() })
8
10
 
9
11
  // 类型契约透传(应用页面可直接 import type { PageOnLoad } from './router',无需深路径)
10
12
  export type {
@@ -1,17 +1,18 @@
1
1
  // src/shims/mp.d.ts
2
2
  // ============================================================
3
- // 微信小程序 API 类型声明垫片(minimal)
3
+ // 微信小程序 API 类型声明垫片(minimal + 官方 typings 接入)
4
4
  //
5
5
  // 职责:
6
- // - 让 wx.* / Page() / App() / Component() 在小程序端代码中通过编译
7
- // - 提供 RouteBuilder / PageOptions 等类型,是 P3(router)、
8
- // P4(编译产物)、P5(pageLifecycle)的类型依据,务必完整
9
- //
10
- // 注意:本文件无 import/export,保持全局声明(ambient)形态
6
+ // - ★B8(types-plus-plan):wx.* / App() / Page() / Component() 参数全部源自官方
7
+ // miniprogram-api-typings(WechatMiniprogram 命名空间),本文件不再自造 wx 类型
8
+ // - 保留 Proteus 自定义类型:RouteContext / RouteBuilder / PageOptions 等(官方不覆盖)
9
+ // - 注意:本文件无 import/export,保持全局声明(ambient)形态
11
10
  // ============================================================
12
11
 
13
- /** wx 全局对象(minimal:任何属性可用,仅供编译通过) */
14
- declare const wx: any
12
+ /// <reference types="miniprogram-api-typings" />
13
+
14
+ /** wx 全局对象(★官方类型:WechatMiniprogram.Wx,含 wx.router 等 Skyline API) */
15
+ declare const wx: WechatMiniprogram.Wx
15
16
 
16
17
  /** Skyline wx.router 自定义路由上下文(官方 CustomRouteContext) */
17
18
  interface RouteContext {
@@ -98,8 +99,7 @@ interface ComponentOptions {
98
99
  }
99
100
 
100
101
  declare function App(options: Record<string, unknown>): void
101
- declare function Page(options: PageOptions): void
102
- declare function Component(options: ComponentOptions): void
102
+ /** 说明:Page/Component/App 全局构造器由官方 miniprogram-api-typings 声明(WechatMiniprogram.Page.Constructor 等),本文件不再重复声明 */
103
103
 
104
104
  /** Skyline worklet 渲染线程全局(仅 worklet 函数内可用) */
105
105
  declare const screenHeight: number
@@ -110,3 +110,15 @@ declare const __PROTEUS_DEBUG__: boolean
110
110
 
111
111
  /** Skyline 渲染开关(mp 构建时由 vite define 注入 proteus.config.skyline) */
112
112
  declare const __PROTEUS_SKYLINE__: boolean
113
+
114
+ /** ★平台编译期宏(条件显隐):构建期替换为该平台字面量,配合 v-if 静态裁剪死分支。
115
+ * 用法:<p-button v-if="__MP__" open-type="contact">客服</p-button>
116
+ * <view v-if="__TARGET__ === 'web'">仅 Web</view>
117
+ * 见 packages/compiler/src/platform-macros.ts */
118
+ declare const __MP__: boolean
119
+ declare const __WEB__: boolean
120
+ declare const __NATIVE__: boolean
121
+ declare const __IOS__: boolean
122
+ declare const __ANDROID__: boolean
123
+ declare const __HARMONY__: boolean
124
+ declare const __TARGET__: 'web' | 'mp' | 'ios' | 'android' | 'harmony' | 'native'
@@ -1,7 +0,0 @@
1
- // scripts/gen-routes.ts —— 编译期路由表生成器 CLI(拆包步骤 7:逻辑来自 @proteus-vue/plugin-vite npm 包)
2
- // 运行:tsx scripts/gen-routes.ts(dev:mp / build:mp 前置步骤)
3
- // 输出:src/router/auto-routes.ts + dist/mp-weixin/{app.json,page.json,component.json}
4
- import config from '../proteus.config'
5
- import { runGenRoutes } from '@proteus-vue/plugin-vite'
6
-
7
- runGenRoutes({ config })
@@ -1,5 +0,0 @@
1
- // scripts/mp-entry-stub.ts
2
- // mp 构建的 rollup 占位入口:真实 app.js 由 vite-plugin-mp-transform 在 buildStart 直出为纯文本资产
3
- // (绕开 rollup 打包——微信 worklet 响应式重执行对打包代码不友好,见 examples/main.mp.ts 注释)
4
- // 构建后此 chunk 会被插件在 generateBundle 中删除
5
- export {}
@@ -1,55 +0,0 @@
1
- // vite.config.ts —— Proteus 工程骨架(拆包步骤 7:插件来自 @proteus-vue/plugin-vite npm 包)
2
- import { defineConfig } from 'vite'
3
- import type { Plugin } from 'vite'
4
- import vue from '@vitejs/plugin-vue'
5
- import { fileURLToPath, URL } from 'node:url'
6
- import config from './proteus.config'
7
- import { mpTransform } from '@proteus-vue/plugin-vite'
8
-
9
- /** 处理 <route> 自定义块虚拟模块(?vue&type=route),保证 Web 构建不报错 */
10
- function routeBlocksPlugin(): Plugin {
11
- return {
12
- name: 'proteus-route-blocks',
13
- enforce: 'pre',
14
- transform(code, id) {
15
- if (id.includes('?vue&type=route')) {
16
- return { code: `export default ${code}`, map: null }
17
- }
18
- return null
19
- },
20
- }
21
- }
22
-
23
- export default defineConfig(({ mode }) => {
24
- const platform = mode === 'mp-weixin' || mode === 'web' ? mode : config.platform
25
- const isMp = platform === 'mp-weixin'
26
-
27
- return {
28
- define: {
29
- __PROTEUS_DEBUG__: process.env.PROTEUS_DEBUG === '1',
30
- // Skyline 开关注入:mp 构建时 __PROTEUS_SKYLINE__ = config.skyline(router/skyline 解耦 config)
31
- __PROTEUS_SKYLINE__: isMp && config.skyline,
32
- },
33
- plugins: isMp
34
- ? [
35
- // 小程序端:独占编译管线(不用 plugin-vue),标准 Vue SFC → wxml/wxss/js
36
- mpTransform({ config }),
37
- ]
38
- : [vue(), routeBlocksPlugin()],
39
- resolve: {
40
- alias: [
41
- { find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
42
- ],
43
- },
44
- build: {
45
- target: 'es2018',
46
- cssCodeSplit: false,
47
- minify: isMp ? false : undefined,
48
- outDir: `dist/${platform}`,
49
- emptyOutDir: !isMp,
50
- rollupOptions: isMp
51
- ? { input: 'scripts/mp-entry-stub.ts', output: { entryFileNames: 'mp-entry.js' } }
52
- : undefined,
53
- },
54
- }
55
- })