@fchc8/vite-plugin-multi-page 1.11.3 → 2.0.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/README-EN.md +192 -217
- package/README.md +190 -215
- package/dist/cli.js +12 -126
- package/dist/index.d.mts +2 -11
- package/dist/index.d.ts +2 -11
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
- 📝 **TypeScript 配置**: 支持 TypeScript 配置文件
|
|
12
12
|
- 🚀 **CLI 工具**: 提供命令行批量构建工具
|
|
13
13
|
- 🔄 **热重载**: 开发服务器支持页面热重载
|
|
14
|
-
- 📦
|
|
14
|
+
- 📦 **扁平化输出**: 支持扁平化构建结果,减少目录层级
|
|
15
|
+
- ⚡ **并发构建**: 支持控制并发构建数量,提升构建效率
|
|
16
|
+
- 🗂️ **资源去重**: 自动去重共享资源,减少构建产物大小
|
|
15
17
|
|
|
16
18
|
## 安装
|
|
17
19
|
|
|
@@ -60,20 +62,10 @@ export default defineConfig(() => ({}));
|
|
|
60
62
|
创建 `multipage.config.ts` 或 `multipage.config.js`:
|
|
61
63
|
|
|
62
64
|
```typescript
|
|
63
|
-
import { defineConfig } from 'vite-plugin-multi-page';
|
|
64
|
-
|
|
65
|
-
// 方式1: 对象配置(推荐)
|
|
66
|
-
export default defineConfig({
|
|
67
|
-
entry: 'src/pages/**/*.{ts,js}',
|
|
68
|
-
template: 'index.html',
|
|
69
|
-
strategies: {
|
|
70
|
-
// 策略配置...
|
|
71
|
-
},
|
|
72
|
-
});
|
|
65
|
+
import { defineConfig } from '@fchc8/vite-plugin-multi-page';
|
|
73
66
|
|
|
74
|
-
// 方式2: 函数配置(动态配置)
|
|
75
67
|
export default defineConfig(context => {
|
|
76
|
-
const { mode
|
|
68
|
+
const { mode } = context;
|
|
77
69
|
const isProduction = mode === 'production';
|
|
78
70
|
|
|
79
71
|
return {
|
|
@@ -83,15 +75,9 @@ export default defineConfig(context => {
|
|
|
83
75
|
// HTML 模板
|
|
84
76
|
template: 'index.html',
|
|
85
77
|
|
|
86
|
-
// 模板占位符
|
|
87
|
-
placeholder: '{{ENTRY_FILE}}',
|
|
88
|
-
|
|
89
78
|
// 排除的文件
|
|
90
79
|
exclude: ['src/shared/**/*.ts'],
|
|
91
80
|
|
|
92
|
-
// 调试模式
|
|
93
|
-
debug: !isProduction || isCLI,
|
|
94
|
-
|
|
95
81
|
// 构建策略
|
|
96
82
|
strategies: {
|
|
97
83
|
default: {
|
|
@@ -121,25 +107,10 @@ export default defineConfig(context => {
|
|
|
121
107
|
|
|
122
108
|
// 页面配置函数
|
|
123
109
|
pageConfigs: context => {
|
|
124
|
-
// 根据文件路径判断应用的策略
|
|
125
110
|
if (context.relativePath.includes('/mobile/')) {
|
|
126
|
-
return {
|
|
127
|
-
strategy: 'mobile',
|
|
128
|
-
define: {
|
|
129
|
-
PAGE_NAME: context.pageName,
|
|
130
|
-
MOBILE_PAGE: true,
|
|
131
|
-
},
|
|
132
|
-
};
|
|
111
|
+
return { strategy: 'mobile' };
|
|
133
112
|
}
|
|
134
|
-
|
|
135
|
-
// 默认策略
|
|
136
|
-
return {
|
|
137
|
-
strategy: 'default',
|
|
138
|
-
define: {
|
|
139
|
-
PAGE_NAME: context.pageName,
|
|
140
|
-
DEFAULT_PAGE: true,
|
|
141
|
-
},
|
|
142
|
-
};
|
|
113
|
+
return { strategy: 'default' };
|
|
143
114
|
},
|
|
144
115
|
};
|
|
145
116
|
});
|
|
@@ -149,8 +120,6 @@ export default defineConfig(context => {
|
|
|
149
120
|
|
|
150
121
|
按照约定创建页面文件:
|
|
151
122
|
|
|
152
|
-
**注意**:即使使用空配置 `defineConfig({})`,插件也会自动使用默认策略处理所有页面,确保最大兼容性。
|
|
153
|
-
|
|
154
123
|
```
|
|
155
124
|
src/pages/
|
|
156
125
|
├── home.js # → /home.html
|
|
@@ -196,67 +165,95 @@ strategies: {
|
|
|
196
165
|
}
|
|
197
166
|
```
|
|
198
167
|
|
|
199
|
-
###
|
|
168
|
+
### 构建产物组织策略
|
|
200
169
|
|
|
201
|
-
|
|
170
|
+
#### 策略分组模式(默认)
|
|
202
171
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
172
|
+
默认情况下,构建结果按策略分组:
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
dist/
|
|
176
|
+
├── default/
|
|
177
|
+
│ ├── home.html
|
|
178
|
+
│ ├── about.html
|
|
179
|
+
│ ├── assets/
|
|
180
|
+
│ │ ├── home-xxx.js
|
|
181
|
+
│ │ ├── about-xxx.js
|
|
182
|
+
│ │ └── shared-resource.svg
|
|
183
|
+
│ └── images/
|
|
184
|
+
├── mobile/
|
|
185
|
+
│ ├── mobile.html
|
|
186
|
+
│ ├── assets/
|
|
187
|
+
│ │ ├── mobile-xxx.js
|
|
188
|
+
│ │ └── button-loading.svg
|
|
189
|
+
│ └── images/
|
|
190
|
+
└── tablet/
|
|
191
|
+
├── tablet.html
|
|
192
|
+
├── assets/
|
|
193
|
+
│ ├── tablet-xxx.js
|
|
194
|
+
│ └── button-loading.svg
|
|
195
|
+
└── images/
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### 扁平化模式(默认)
|
|
199
|
+
|
|
200
|
+
扁平化输出默认启用。使用 `--no-flatten` 参数禁用它:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# 默认行为(扁平化输出)
|
|
204
|
+
npx vite-mp
|
|
205
|
+
|
|
206
|
+
# 禁用扁平化输出
|
|
207
|
+
npx vite-mp --no-flatten
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
扁平化后的结构:
|
|
211
|
+
|
|
212
|
+
```
|
|
213
|
+
dist/
|
|
214
|
+
├── home.html
|
|
215
|
+
├── about.html
|
|
216
|
+
├── mobile.html
|
|
217
|
+
├── tablet.html
|
|
218
|
+
├── assets/
|
|
219
|
+
│ ├── home-xxx.js
|
|
220
|
+
│ ├── about-xxx.js
|
|
221
|
+
│ ├── mobile-xxx.js
|
|
222
|
+
│ ├── tablet-xxx.js
|
|
223
|
+
│ └── shared-resource.svg
|
|
224
|
+
├── images/
|
|
225
|
+
├── favicon.ico
|
|
226
|
+
└── some.css
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### 扁平化模式的优势
|
|
230
|
+
|
|
231
|
+
- ✅ **简化部署**: 所有文件在根目录,部署更简单
|
|
232
|
+
- ✅ **资源去重**: 自动去重相同内容的资源文件
|
|
233
|
+
- ✅ **减少层级**: 避免深层嵌套的目录结构
|
|
234
|
+
- ✅ **统一管理**: 所有资源集中管理,便于CDN配置
|
|
235
|
+
|
|
236
|
+
### 并发构建控制
|
|
237
|
+
|
|
238
|
+
通过 `--concurrency` 参数控制并发构建数量:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# 默认并发数为3
|
|
242
|
+
npx vite-mp
|
|
243
|
+
|
|
244
|
+
# 设置并发数为1(串行构建)
|
|
245
|
+
npx vite-mp --concurrency 1
|
|
246
|
+
|
|
247
|
+
# 设置并发数为5(高并发)
|
|
248
|
+
npx vite-mp --concurrency 5
|
|
208
249
|
```
|
|
209
250
|
|
|
210
|
-
####
|
|
211
|
-
|
|
212
|
-
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
├── home.html
|
|
217
|
-
├── about.html
|
|
218
|
-
├── mobile.html
|
|
219
|
-
└── assets/
|
|
220
|
-
├── home-xxx.js
|
|
221
|
-
├── about-xxx.js
|
|
222
|
-
└── shared-resource.svg
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
- **`page`**: 每个页面独立打包,各自拥有完整的资源副本
|
|
226
|
-
```
|
|
227
|
-
dist/
|
|
228
|
-
├── home/
|
|
229
|
-
│ ├── index.html
|
|
230
|
-
│ ├── assets/
|
|
231
|
-
│ │ ├── home-xxx.js
|
|
232
|
-
│ │ └── button-loading.svg
|
|
233
|
-
│ └── images/
|
|
234
|
-
├── about/
|
|
235
|
-
│ ├── index.html
|
|
236
|
-
│ ├── assets/
|
|
237
|
-
│ │ ├── about-xxx.js
|
|
238
|
-
│ │ └── button-loading.svg
|
|
239
|
-
│ └── images/
|
|
240
|
-
└── mobile/
|
|
241
|
-
├── index.html
|
|
242
|
-
├── assets/
|
|
243
|
-
│ ├── mobile-xxx.js
|
|
244
|
-
│ └── button-loading.svg
|
|
245
|
-
└── images/
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
#### Page模式的优势
|
|
249
|
-
|
|
250
|
-
- ✅ **完全独立**: 每个页面目录包含所有必需资源,可独立部署
|
|
251
|
-
- ✅ **避免冲突**: 彻底解决了共享资源的归属问题
|
|
252
|
-
- ✅ **简洁命名**: 资源文件使用干净的文件名,无页面前缀
|
|
253
|
-
- ✅ **部署友好**: 支持CDN分发、微前端等架构模式
|
|
254
|
-
|
|
255
|
-
> **注意**:
|
|
256
|
-
>
|
|
257
|
-
> - Page模式会为每个页面创建资源副本,可能增加总体构建产物大小
|
|
258
|
-
> - 适合需要独立部署或有严格资源隔离需求的场景
|
|
259
|
-
> - `public/` 目录中的静态资源会自动复制到每个页面目录中
|
|
251
|
+
#### 并发构建的优势
|
|
252
|
+
|
|
253
|
+
- ⚡ **提升效率**: 多策略并行构建,减少总构建时间
|
|
254
|
+
- 🔧 **资源控制**: 避免同时构建过多策略导致系统资源过载
|
|
255
|
+
- 🎯 **灵活配置**: 根据机器性能调整并发数量
|
|
256
|
+
- 📊 **进度可见**: 调试模式下显示批次构建进度
|
|
260
257
|
|
|
261
258
|
### 页面策略分配
|
|
262
259
|
|
|
@@ -283,14 +280,26 @@ pageConfigs: context => {
|
|
|
283
280
|
### 批量构建
|
|
284
281
|
|
|
285
282
|
```bash
|
|
286
|
-
#
|
|
283
|
+
# 构建所有策略(默认扁平化输出)
|
|
287
284
|
npx vite-mp
|
|
288
285
|
|
|
286
|
+
# 禁用扁平化输出结构
|
|
287
|
+
npx vite-mp --no-flatten
|
|
288
|
+
|
|
289
|
+
# 控制并发构建数量
|
|
290
|
+
npx vite-mp --concurrency 2
|
|
291
|
+
|
|
292
|
+
# 构建指定策略
|
|
293
|
+
npx vite-mp --strategy mobile,tablet
|
|
294
|
+
|
|
289
295
|
# 传递额外的 Vite 参数
|
|
290
296
|
npx vite-mp --host --port 3000
|
|
291
297
|
|
|
292
298
|
# 启用调试模式
|
|
293
299
|
npx vite-mp --debug
|
|
300
|
+
|
|
301
|
+
# 组合使用
|
|
302
|
+
npx vite-mp --concurrency 4 --debug
|
|
294
303
|
```
|
|
295
304
|
|
|
296
305
|
### 开发服务器
|
|
@@ -303,133 +312,95 @@ npm run dev
|
|
|
303
312
|
npm run dev -- --strategy mobile
|
|
304
313
|
```
|
|
305
314
|
|
|
306
|
-
|
|
315
|
+
### 静态资源预览
|
|
307
316
|
|
|
308
|
-
|
|
317
|
+
构建完成后,可以使用多种方式预览静态资源:
|
|
309
318
|
|
|
310
|
-
|
|
319
|
+
```bash
|
|
320
|
+
# 使用 serve 工具(推荐)
|
|
321
|
+
npx serve dist -p 3000
|
|
311
322
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
export default defineConfig({
|
|
315
|
-
entry: 'src/pages/**/*.{ts,js}',
|
|
316
|
-
template: 'index.html',
|
|
317
|
-
merge: 'page', // 启用Page模式
|
|
318
|
-
strategies: {
|
|
319
|
-
default: {
|
|
320
|
-
build: {
|
|
321
|
-
sourcemap: false,
|
|
322
|
-
minify: 'esbuild',
|
|
323
|
-
},
|
|
324
|
-
},
|
|
325
|
-
mobile: {
|
|
326
|
-
build: {
|
|
327
|
-
target: ['es2015'],
|
|
328
|
-
minify: 'terser',
|
|
329
|
-
},
|
|
330
|
-
},
|
|
331
|
-
},
|
|
332
|
-
pageConfigs: context => {
|
|
333
|
-
if (context.relativePath.includes('/mobile/')) {
|
|
334
|
-
return { strategy: 'mobile' };
|
|
335
|
-
}
|
|
336
|
-
return { strategy: 'default' };
|
|
337
|
-
},
|
|
338
|
-
});
|
|
339
|
-
```
|
|
323
|
+
# 使用 http-server
|
|
324
|
+
npx http-server dist -p 3000
|
|
340
325
|
|
|
341
|
-
|
|
326
|
+
# 使用 Python 简单服务器
|
|
327
|
+
python -m http.server 3000 --directory dist
|
|
342
328
|
|
|
343
|
-
|
|
329
|
+
# 使用 Node.js 简单服务器
|
|
330
|
+
npx http-server dist
|
|
331
|
+
```
|
|
344
332
|
|
|
345
|
-
|
|
333
|
+
访问地址:
|
|
346
334
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
import buttonIcon from '../button-loading.svg'; // 共享资源
|
|
335
|
+
- 默认(扁平化模式):`http://localhost:3000/home.html`
|
|
336
|
+
- 策略分组模式:`http://localhost:3000/default/home.html`(使用 `--no-flatten`)
|
|
350
337
|
|
|
351
|
-
|
|
352
|
-
import buttonIcon from '../button-loading.svg'; // 相同的共享资源
|
|
353
|
-
```
|
|
338
|
+
## 使用示例
|
|
354
339
|
|
|
355
|
-
|
|
340
|
+
### 默认扁平化构建
|
|
356
341
|
|
|
357
|
-
|
|
358
|
-
- `dist/mobile/assets/button-loading-xxx.svg`
|
|
342
|
+
插件默认使用扁平化输出构建多策略应用:
|
|
359
343
|
|
|
360
|
-
|
|
344
|
+
```bash
|
|
345
|
+
# 默认扁平化构建,所有文件在根目录
|
|
346
|
+
npx vite-mp
|
|
361
347
|
|
|
362
|
-
|
|
363
|
-
-
|
|
364
|
-
- `VITE_MULTI_PAGE_STRATEGY`: 当前构建策略(自动设置)
|
|
365
|
-
- `VITE_MULTI_PAGE_CURRENT_PAGE`: 当前页面名称(Page模式下自动设置)
|
|
366
|
-
- `VITE_MULTI_PAGE_MERGE_MODE`: 当前合并模式(Page模式下自动设置)
|
|
367
|
-
- `IS_MOBILE`: 移动端标识 (在 define 中配置)
|
|
368
|
-
- `API_BASE`: API 基础地址 (在 define 中配置)
|
|
348
|
+
# 高并发扁平化构建
|
|
349
|
+
npx vite-mp --concurrency 5
|
|
369
350
|
|
|
370
|
-
|
|
351
|
+
# 只构建移动端和平板端策略(默认扁平化)
|
|
352
|
+
npx vite-mp --strategy mobile,tablet
|
|
353
|
+
```
|
|
371
354
|
|
|
372
|
-
|
|
355
|
+
构建结果:
|
|
373
356
|
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
// 根据页面路径添加特定变量
|
|
391
|
-
if (relativePath.includes('/mobile/')) {
|
|
392
|
-
envs.VITE_IS_MOBILE = 'true';
|
|
393
|
-
envs.VITE_API_URL = 'https://mobile-api.example.com';
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
return envs;
|
|
397
|
-
},
|
|
398
|
-
});
|
|
357
|
+
```
|
|
358
|
+
dist/
|
|
359
|
+
├── home.html # 默认策略页面
|
|
360
|
+
├── about.html # 默认策略页面
|
|
361
|
+
├── mobile.html # 移动端策略页面
|
|
362
|
+
├── tablet.html # 平板端策略页面
|
|
363
|
+
├── assets/ # 统一资源目录
|
|
364
|
+
│ ├── home-xxx.js
|
|
365
|
+
│ ├── about-xxx.js
|
|
366
|
+
│ ├── mobile-xxx.js
|
|
367
|
+
│ ├── tablet-xxx.js
|
|
368
|
+
│ └── shared-resource.svg
|
|
369
|
+
├── images/
|
|
370
|
+
├── favicon.ico
|
|
371
|
+
└── some.css
|
|
399
372
|
```
|
|
400
373
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
`pageEnvs` 函数接收一个页面上下文对象,包含以下信息:
|
|
374
|
+
### 并发构建优化
|
|
404
375
|
|
|
405
|
-
|
|
406
|
-
- `strategy`: 分配给该页面的策略名称
|
|
407
|
-
- `filePath`: 页面入口文件的绝对路径
|
|
408
|
-
- `relativePath`: 页面入口文件的相对路径
|
|
376
|
+
根据机器性能调整并发数:
|
|
409
377
|
|
|
410
|
-
|
|
378
|
+
```bash
|
|
379
|
+
# 低配置机器:串行构建
|
|
380
|
+
npx vite-mp --concurrency 1
|
|
411
381
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
3. **构建信息**: 注入构建时间戳、版本号等信息
|
|
415
|
-
4. **功能开关**: 为特定页面启用或禁用功能
|
|
382
|
+
# 高配置机器:高并发构建
|
|
383
|
+
npx vite-mp --concurrency 8
|
|
416
384
|
|
|
417
|
-
|
|
385
|
+
# 调试模式查看构建进度
|
|
386
|
+
npx vite-mp --concurrency 4 --debug
|
|
387
|
+
```
|
|
418
388
|
|
|
419
|
-
|
|
389
|
+
### 生产环境部署
|
|
420
390
|
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
console.log('当前策略:', import.meta.env.VITE_CURRENT_STRATEGY);
|
|
425
|
-
console.log('构建时间:', import.meta.env.VITE_BUILD_TIMESTAMP);
|
|
391
|
+
```bash
|
|
392
|
+
# 生产环境构建(默认扁平化)
|
|
393
|
+
npx vite-mp --concurrency 4
|
|
426
394
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
395
|
+
# 构建后可直接部署到CDN
|
|
396
|
+
# 所有资源都在根目录,便于CDN配置
|
|
430
397
|
```
|
|
431
398
|
|
|
432
|
-
|
|
399
|
+
## 环境变量
|
|
400
|
+
|
|
401
|
+
- `VITE_MULTI_PAGE_STRATEGY`: 当前构建策略(自动设置)
|
|
402
|
+
- `IS_MOBILE`: 移动端标识 (在 define 中配置)
|
|
403
|
+
- `API_BASE`: API 基础地址 (在 define 中配置)
|
|
433
404
|
|
|
434
405
|
## TypeScript 支持
|
|
435
406
|
|
|
@@ -453,33 +424,37 @@ export default config;
|
|
|
453
424
|
|
|
454
425
|
### 配置选项
|
|
455
426
|
|
|
456
|
-
| 选项 | 类型 | 默认值 | 描述
|
|
457
|
-
| ------------- | -------------------------- | -------------------------- |
|
|
458
|
-
| `entry` | `string` | `'src/pages/**/*.{ts,js}'` | 页面入口匹配规则
|
|
459
|
-
| `template` | `string` | `'index.html'` | HTML 模板文件
|
|
460
|
-
| `placeholder` | `string` | `'{{ENTRY_FILE}}'` | 模板占位符
|
|
461
|
-
| `exclude` | `string[]` | `[]` | 排除的文件模式
|
|
462
|
-
| `debug` | `boolean` | `false` | 启用调试日志
|
|
463
|
-
| `
|
|
464
|
-
| `
|
|
465
|
-
|
|
466
|
-
|
|
427
|
+
| 选项 | 类型 | 默认值 | 描述 |
|
|
428
|
+
| ------------- | -------------------------- | -------------------------- | ---------------- |
|
|
429
|
+
| `entry` | `string` | `'src/pages/**/*.{ts,js}'` | 页面入口匹配规则 |
|
|
430
|
+
| `template` | `string` | `'index.html'` | HTML 模板文件 |
|
|
431
|
+
| `placeholder` | `string` | `'{{ENTRY_FILE}}'` | 模板占位符 |
|
|
432
|
+
| `exclude` | `string[]` | `[]` | 排除的文件模式 |
|
|
433
|
+
| `debug` | `boolean` | `false` | 启用调试日志 |
|
|
434
|
+
| `strategies` | `Record<string, Strategy>` | `{}` | 构建策略配置 |
|
|
435
|
+
| `pageConfigs` | `Function \| Object` | `{}` | 页面配置 |
|
|
436
|
+
|
|
437
|
+
### CLI 参数
|
|
438
|
+
|
|
439
|
+
| 参数 | 类型 | 默认值 | 描述 |
|
|
440
|
+
| --------------- | --------- | ------- | -------------------------- |
|
|
441
|
+
| `--flatten` | `boolean` | `true` | 启用扁平化输出结构(默认) |
|
|
442
|
+
| `--no-flatten` | `boolean` | `false` | 禁用扁平化输出结构 |
|
|
443
|
+
| `--concurrency` | `number` | `3` | 并发构建数量 |
|
|
444
|
+
| `--strategy` | `string` | - | 指定构建策略(可多次使用) |
|
|
445
|
+
| `--debug` | `boolean` | `false` | 启用调试模式 |
|
|
446
|
+
| `--cwd` | `string` | - | 指定工作目录 |
|
|
447
|
+
| `--help` | `boolean` | `false` | 显示帮助信息 |
|
|
467
448
|
|
|
468
449
|
### 工具函数
|
|
469
450
|
|
|
470
451
|
```typescript
|
|
471
|
-
import { defineConfig
|
|
452
|
+
import { defineConfig } from '@fchc8/vite-plugin-multi-page';
|
|
472
453
|
|
|
473
454
|
// 定义配置
|
|
474
455
|
export default defineConfig(context => ({
|
|
475
456
|
// 配置选项
|
|
476
457
|
}));
|
|
477
|
-
|
|
478
|
-
// 配置转换
|
|
479
|
-
const transform = defineConfigTransform((config, context) => {
|
|
480
|
-
// 修改配置
|
|
481
|
-
return config;
|
|
482
|
-
});
|
|
483
458
|
```
|
|
484
459
|
|
|
485
460
|
## 示例项目
|