@fchc8/vite-plugin-multi-page 1.1.0 → 1.3.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 +183 -337
- package/README.md +175 -423
- package/dist/cli.js +649 -0
- package/dist/index.d.mts +43 -69
- package/dist/index.d.ts +43 -69
- package/dist/index.js +653 -428
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +649 -429
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -3
package/README-EN.md
CHANGED
|
@@ -1,424 +1,270 @@
|
|
|
1
1
|
# vite-plugin-multi-page
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> 中文文档 | [中文文档](./README.md)
|
|
4
4
|
|
|
5
|
-
A powerful Vite plugin for building multi-page applications with smart file routing and
|
|
5
|
+
A powerful Vite plugin for building multi-page applications with smart file routing and multi-strategy builds.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Features
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
- 🎨 **Developer Friendly**: Detailed debug logs and hot reload support
|
|
9
|
+
- 🎯 **Multi-page support**: Automatically discover page entry files
|
|
10
|
+
- 🔧 **Multi-strategy builds**: Support configuring different build strategies for different pages
|
|
11
|
+
- 📝 **TypeScript configuration**: Support TypeScript configuration files
|
|
12
|
+
- 🚀 **CLI tool**: Provide a command-line batch build tool
|
|
13
|
+
- 🔄 **Hot reload**: Development server supports page hot reload
|
|
14
|
+
- 📦 **Smart merge**: Automatically merge multi-strategy build results
|
|
16
15
|
|
|
17
|
-
##
|
|
16
|
+
## Installation
|
|
18
17
|
|
|
19
18
|
```bash
|
|
20
|
-
npm install
|
|
21
|
-
# or
|
|
22
|
-
yarn add @fchc8/vite-plugin-multi-page
|
|
23
|
-
# or
|
|
24
|
-
pnpm add @fchc8/vite-plugin-multi-page
|
|
19
|
+
npm install vite-plugin-multi-page --save-dev
|
|
25
20
|
```
|
|
26
21
|
|
|
27
|
-
##
|
|
22
|
+
## Quick Start
|
|
28
23
|
|
|
29
|
-
###
|
|
24
|
+
### 1. Create a configuration file
|
|
25
|
+
|
|
26
|
+
Create a `multipage.config.ts` or `multipage.config.js`:
|
|
30
27
|
|
|
31
28
|
```typescript
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
export default context => {
|
|
30
|
+
const { mode, command, isCLI } = context;
|
|
31
|
+
const isProduction = mode === 'production';
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
entry: 'src/pages/**/*.{ts,js}',
|
|
40
|
-
template: 'index.html',
|
|
41
|
-
exclude: ['src/main.ts'],
|
|
42
|
-
debug: true,
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
45
|
-
});
|
|
46
|
-
```
|
|
33
|
+
return {
|
|
34
|
+
// Page entry matching rule
|
|
35
|
+
entry: 'src/pages/**/*.{ts,js}',
|
|
47
36
|
|
|
48
|
-
|
|
37
|
+
// HTML template
|
|
38
|
+
template: 'index.html',
|
|
49
39
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
├── src/
|
|
53
|
-
│ └── pages/
|
|
54
|
-
│ ├── home.ts → /home.html
|
|
55
|
-
│ ├── about.ts → /about.html
|
|
56
|
-
│ ├── admin/
|
|
57
|
-
│ │ └── dashboard.ts → /dashboard.html
|
|
58
|
-
│ └── mobile/
|
|
59
|
-
│ └── app.js → /app.html
|
|
60
|
-
├── index.html
|
|
61
|
-
├── admin.html
|
|
62
|
-
└── mobile.html
|
|
63
|
-
```
|
|
40
|
+
// Template placeholder
|
|
41
|
+
placeholder: '{{ENTRY_FILE}}',
|
|
64
42
|
|
|
65
|
-
|
|
43
|
+
// Excluded files
|
|
44
|
+
exclude: ['src/shared/**/*.ts'],
|
|
66
45
|
|
|
67
|
-
|
|
46
|
+
// Debug mode
|
|
47
|
+
debug: !isProduction || isCLI,
|
|
68
48
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
viteMultiPage({
|
|
76
|
-
entry: 'src/pages/**/*.{ts,js}',
|
|
77
|
-
|
|
78
|
-
// Define build strategies
|
|
79
|
-
buildStrategies: {
|
|
80
|
-
// Modern browser strategy
|
|
81
|
-
default: {
|
|
82
|
-
viteConfig: {
|
|
83
|
-
define: {
|
|
84
|
-
'process.env.BUILD_TYPE': '"modern"',
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
output: {
|
|
88
|
-
format: 'es',
|
|
89
|
-
entryFileNames: 'assets/[name]-[hash].js',
|
|
90
|
-
},
|
|
91
|
-
build: {
|
|
92
|
-
target: 'es2015',
|
|
93
|
-
minify: 'esbuild',
|
|
94
|
-
sourcemap: true,
|
|
95
|
-
},
|
|
49
|
+
// Build strategy
|
|
50
|
+
strategies: {
|
|
51
|
+
default: {
|
|
52
|
+
define: {
|
|
53
|
+
IS_DEFAULT: true,
|
|
54
|
+
API_BASE: isProduction ? '"https://api.example.com"' : '"http://localhost:3001/api"',
|
|
96
55
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
viteConfig: {
|
|
101
|
-
define: {
|
|
102
|
-
'process.env.BUILD_TYPE': '"legacy"',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
output: {
|
|
106
|
-
format: 'iife',
|
|
107
|
-
entryFileNames: 'legacy/[name].js',
|
|
108
|
-
},
|
|
109
|
-
build: {
|
|
110
|
-
target: 'es5',
|
|
111
|
-
minify: 'terser',
|
|
112
|
-
sourcemap: false,
|
|
113
|
-
},
|
|
56
|
+
build: {
|
|
57
|
+
sourcemap: !isProduction,
|
|
58
|
+
minify: isProduction ? 'esbuild' : false,
|
|
114
59
|
},
|
|
60
|
+
},
|
|
115
61
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
build: {
|
|
127
|
-
target: 'es2018',
|
|
128
|
-
chunkSizeWarningLimit: 300,
|
|
129
|
-
},
|
|
62
|
+
mobile: {
|
|
63
|
+
define: {
|
|
64
|
+
IS_MOBILE: true,
|
|
65
|
+
API_BASE: isProduction
|
|
66
|
+
? '"https://mobile-api.example.com"'
|
|
67
|
+
: '"http://localhost:3001/mobile-api"',
|
|
68
|
+
},
|
|
69
|
+
build: {
|
|
70
|
+
target: ['es2015', 'chrome58', 'safari11'],
|
|
71
|
+
minify: isProduction ? 'terser' : false,
|
|
130
72
|
},
|
|
131
73
|
},
|
|
132
|
-
}
|
|
133
|
-
],
|
|
134
|
-
});
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Function Configuration
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
viteMultiPage({
|
|
141
|
-
entry: 'src/pages/**/*.{ts,js}',
|
|
74
|
+
},
|
|
142
75
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
76
|
+
// Page configuration function
|
|
77
|
+
pageConfigs: context => {
|
|
78
|
+
// Determine the application strategy based on the file path
|
|
79
|
+
if (context.relativePath.includes('/mobile/')) {
|
|
80
|
+
return {
|
|
81
|
+
strategy: 'mobile',
|
|
82
|
+
define: {
|
|
83
|
+
PAGE_NAME: context.pageName,
|
|
84
|
+
MOBILE_PAGE: true,
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
146
88
|
|
|
147
|
-
|
|
148
|
-
if (pageName.startsWith('admin')) {
|
|
89
|
+
// Default strategy
|
|
149
90
|
return {
|
|
150
91
|
strategy: 'default',
|
|
151
|
-
template: 'admin.html',
|
|
152
92
|
define: {
|
|
153
|
-
|
|
93
|
+
PAGE_NAME: context.pageName,
|
|
94
|
+
DEFAULT_PAGE: true,
|
|
154
95
|
},
|
|
155
96
|
};
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (relativePath.includes('/mobile/')) {
|
|
160
|
-
return {
|
|
161
|
-
strategy: 'mobile',
|
|
162
|
-
template: 'mobile.html',
|
|
163
|
-
define: {
|
|
164
|
-
'process.env.API_BASE': '"https://mobile-api.example.com"',
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Default configuration
|
|
170
|
-
return {
|
|
171
|
-
strategy: 'default',
|
|
172
|
-
};
|
|
173
|
-
},
|
|
174
|
-
});
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
};
|
|
175
100
|
```
|
|
176
101
|
|
|
177
|
-
###
|
|
102
|
+
### 2. Configure Vite
|
|
178
103
|
|
|
179
|
-
|
|
180
|
-
viteMultiPage({
|
|
181
|
-
entry: 'src/pages/**/*.{ts,js}',
|
|
182
|
-
|
|
183
|
-
pageConfigs: {
|
|
184
|
-
// Exact match
|
|
185
|
-
home: {
|
|
186
|
-
strategy: 'default',
|
|
187
|
-
template: 'home.html',
|
|
188
|
-
},
|
|
104
|
+
Add the plugin in `vite.config.ts`:
|
|
189
105
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
template: 'admin.html',
|
|
194
|
-
},
|
|
106
|
+
```typescript
|
|
107
|
+
import { defineConfig } from 'vite';
|
|
108
|
+
import viteMultiPage from 'vite-plugin-multi-page';
|
|
195
109
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
strategy: 'mobile',
|
|
199
|
-
match: ['**/mobile/**', '*mobile*'],
|
|
200
|
-
template: 'mobile.html',
|
|
201
|
-
},
|
|
202
|
-
},
|
|
110
|
+
export default defineConfig({
|
|
111
|
+
plugins: [viteMultiPage()],
|
|
203
112
|
});
|
|
204
113
|
```
|
|
205
114
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
### MultiPageOptions
|
|
209
|
-
|
|
210
|
-
| Option | Type | Default | Description |
|
|
211
|
-
| ----------------- | -------------------------------------------------- | -------------------------------------- | --------------------------- |
|
|
212
|
-
| `entry` | `string` | `"src/**/*.{ts,js}"` | Entry file matching pattern |
|
|
213
|
-
| `template` | `string` | `"index.html"` | Default HTML template |
|
|
214
|
-
| `exclude` | `string[]` | `["src/main.ts", "src/vite-env.d.ts"]` | Files to exclude |
|
|
215
|
-
| `placeholder` | `string` | `"{{ENTRY_FILE}}"` | Placeholder in template |
|
|
216
|
-
| `debug` | `boolean` | `false` | Enable debug logs |
|
|
217
|
-
| `buildStrategies` | `Record<string, BuildStrategy>` | `{}` | Build strategy definitions |
|
|
218
|
-
| `pageConfigs` | `Record<string, PageConfig> \| PageConfigFunction` | `{}` | Page configurations |
|
|
115
|
+
### 3. Create page files
|
|
219
116
|
|
|
220
|
-
|
|
117
|
+
Create page files according to the convention:
|
|
221
118
|
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
119
|
+
```
|
|
120
|
+
src/pages/
|
|
121
|
+
├── home.js # → /home.html
|
|
122
|
+
├── about.js # → /about.html
|
|
123
|
+
├── mobile/
|
|
124
|
+
│ └── main.ts # → /mobile.html (mobile strategy)
|
|
125
|
+
└── admin/
|
|
126
|
+
└── main.ts # → /admin.html
|
|
127
|
+
```
|
|
228
128
|
|
|
229
|
-
|
|
230
|
-
output?: {
|
|
231
|
-
format?: 'es' | 'cjs' | 'umd' | 'iife';
|
|
232
|
-
dir?: string;
|
|
233
|
-
entryFileNames?: string;
|
|
234
|
-
chunkFileNames?: string;
|
|
235
|
-
assetFileNames?: string;
|
|
236
|
-
globals?: Record<string, string>;
|
|
237
|
-
external?: string | string[] | ((id: string) => boolean);
|
|
238
|
-
};
|
|
129
|
+
## Page discovery rules
|
|
239
130
|
|
|
240
|
-
|
|
241
|
-
build?: {
|
|
242
|
-
target?: string | string[];
|
|
243
|
-
minify?: boolean | 'terser' | 'esbuild';
|
|
244
|
-
sourcemap?: boolean | 'inline' | 'hidden';
|
|
245
|
-
lib?: boolean | LibraryOptions;
|
|
246
|
-
cssCodeSplit?: boolean;
|
|
247
|
-
cssTarget?: string | string[];
|
|
248
|
-
rollupOptions?: any;
|
|
249
|
-
// ... more Vite build options
|
|
250
|
-
};
|
|
131
|
+
The plugin discovers page entries according to the following rules:
|
|
251
132
|
|
|
252
|
-
|
|
253
|
-
|
|
133
|
+
1. **First-level files** (priority 1): `src/pages/home.js` → `/home.html`
|
|
134
|
+
2. **Directory main files** (priority 2): `src/pages/mobile/main.ts` → `/mobile.html`
|
|
254
135
|
|
|
255
|
-
|
|
256
|
-
alias?: Record<string, string>;
|
|
136
|
+
**Directory priority rule**: If both `src/pages/about.js` and `src/pages/about/main.ts` exist, `src/pages/about/main.ts` will be used.
|
|
257
137
|
|
|
258
|
-
|
|
259
|
-
server?: ServerOptions;
|
|
138
|
+
## Build strategies
|
|
260
139
|
|
|
261
|
-
|
|
262
|
-
css?: CSSOptions;
|
|
140
|
+
### Strategy configuration
|
|
263
141
|
|
|
264
|
-
|
|
265
|
-
optimizeDeps?: DepOptimizationOptions;
|
|
266
|
-
}
|
|
267
|
-
```
|
|
268
|
-
|
|
269
|
-
### PageConfig
|
|
142
|
+
策略配置支持所有 Vite 配置选项:
|
|
270
143
|
|
|
271
144
|
```typescript
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
145
|
+
strategies: {
|
|
146
|
+
mobile: {
|
|
147
|
+
define: {
|
|
148
|
+
IS_MOBILE: true,
|
|
149
|
+
},
|
|
150
|
+
build: {
|
|
151
|
+
target: ['es2015'],
|
|
152
|
+
minify: 'terser',
|
|
153
|
+
terserOptions: {
|
|
154
|
+
compress: {
|
|
155
|
+
drop_console: true,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
// Other Vite configurations...
|
|
160
|
+
},
|
|
280
161
|
}
|
|
281
162
|
```
|
|
282
163
|
|
|
283
|
-
|
|
164
|
+
### Page strategy assignment
|
|
284
165
|
|
|
285
|
-
|
|
166
|
+
Assign strategies to pages through the `pageConfigs` function:
|
|
286
167
|
|
|
287
168
|
```typescript
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
viteConfig: {
|
|
291
|
-
define: { 'process.env.APP_TYPE': '"admin"' }
|
|
292
|
-
},
|
|
293
|
-
build: {
|
|
294
|
-
target: 'es2015',
|
|
295
|
-
sourcemap: true
|
|
296
|
-
}
|
|
297
|
-
},
|
|
169
|
+
pageConfigs: context => {
|
|
170
|
+
const { pageName, relativePath } = context;
|
|
298
171
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
define: { 'process.env.APP_TYPE': '"public"' }
|
|
302
|
-
},
|
|
303
|
-
build: {
|
|
304
|
-
target: 'es5',
|
|
305
|
-
minify: 'terser'
|
|
306
|
-
}
|
|
172
|
+
if (relativePath.includes('/mobile/')) {
|
|
173
|
+
return { strategy: 'mobile' };
|
|
307
174
|
}
|
|
308
|
-
}
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
### 2. Mobile Optimization
|
|
312
175
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
mobile: {
|
|
316
|
-
viteConfig: {
|
|
317
|
-
css: { devSourcemap: true },
|
|
318
|
-
optimizeDeps: { include: ['@mobile/utils'] }
|
|
319
|
-
},
|
|
320
|
-
build: {
|
|
321
|
-
target: 'es2018',
|
|
322
|
-
chunkSizeWarningLimit: 300,
|
|
323
|
-
cssCodeSplit: true
|
|
324
|
-
}
|
|
176
|
+
if (pageName.startsWith('admin')) {
|
|
177
|
+
return { strategy: 'admin' };
|
|
325
178
|
}
|
|
326
|
-
|
|
179
|
+
|
|
180
|
+
return { strategy: 'default' };
|
|
181
|
+
};
|
|
327
182
|
```
|
|
328
183
|
|
|
329
|
-
|
|
184
|
+
## 命令行工具
|
|
330
185
|
|
|
331
|
-
|
|
332
|
-
buildStrategies: {
|
|
333
|
-
library: {
|
|
334
|
-
build: {
|
|
335
|
-
lib: {
|
|
336
|
-
entry: 'src/index.ts',
|
|
337
|
-
name: 'MyLibrary',
|
|
338
|
-
formats: ['es', 'umd']
|
|
339
|
-
},
|
|
340
|
-
minify: false,
|
|
341
|
-
sourcemap: true
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
```
|
|
186
|
+
### 批量构建
|
|
346
187
|
|
|
347
|
-
|
|
188
|
+
```bash
|
|
189
|
+
# Build all strategies
|
|
190
|
+
npx vite-mp
|
|
348
191
|
|
|
349
|
-
|
|
192
|
+
# Pass additional Vite parameters
|
|
193
|
+
npx vite-mp --host --port 3000
|
|
350
194
|
|
|
351
|
-
|
|
352
|
-
-
|
|
353
|
-
|
|
354
|
-
- Different HTML templates
|
|
355
|
-
- Function configuration examples
|
|
195
|
+
# Enable debug mode
|
|
196
|
+
npx vite-mp --debug
|
|
197
|
+
```
|
|
356
198
|
|
|
357
|
-
###
|
|
199
|
+
### 开发服务器
|
|
358
200
|
|
|
359
201
|
```bash
|
|
360
|
-
#
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
#
|
|
364
|
-
npm run
|
|
365
|
-
cd example
|
|
366
|
-
npm install # Install example dependencies
|
|
367
|
-
npm run dev # Run development server
|
|
368
|
-
|
|
369
|
-
# Method 3: Use root scripts
|
|
370
|
-
npm run example:dev # Development mode
|
|
371
|
-
npm run example:build # Build
|
|
372
|
-
npm run example:preview # Preview build results
|
|
202
|
+
# Start development server (all pages)
|
|
203
|
+
npm run dev
|
|
204
|
+
|
|
205
|
+
# Only display pages with specific strategies
|
|
206
|
+
npm run dev -- --strategy mobile
|
|
373
207
|
```
|
|
374
208
|
|
|
375
|
-
|
|
209
|
+
## Environment variables
|
|
376
210
|
|
|
377
|
-
|
|
211
|
+
- `VITE_BUILD_STRATEGY`: Specify a single strategy build
|
|
212
|
+
- `IS_MOBILE`: Mobile identifier (configured in define)
|
|
213
|
+
- `API_BASE`: API base address (configured in define)
|
|
378
214
|
|
|
379
|
-
|
|
380
|
-
- `/about.html` - About page (default strategy)
|
|
381
|
-
- `/dashboard.html` - Admin dashboard (modern ES syntax + dedicated template)
|
|
382
|
-
- `/app.html` - Mobile app (ES5 compatible syntax + mobile template)
|
|
383
|
-
- `/index.html` - Component library docs (library mode + docs template)
|
|
215
|
+
## TypeScript support
|
|
384
216
|
|
|
385
|
-
|
|
217
|
+
The plugin fully supports TypeScript configuration files:
|
|
386
218
|
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
cd vite-plugin-multi-page
|
|
219
|
+
```typescript
|
|
220
|
+
// multipage.config.ts
|
|
221
|
+
import type { ConfigFunction } from 'vite-plugin-multi-page';
|
|
391
222
|
|
|
392
|
-
|
|
393
|
-
|
|
223
|
+
const config: ConfigFunction = context => {
|
|
224
|
+
return {
|
|
225
|
+
entry: 'src/pages/**/*.{ts,js}',
|
|
226
|
+
// ... other configurations
|
|
227
|
+
};
|
|
228
|
+
};
|
|
394
229
|
|
|
395
|
-
|
|
396
|
-
|
|
230
|
+
export default config;
|
|
231
|
+
```
|
|
397
232
|
|
|
398
|
-
|
|
399
|
-
pnpm type-check
|
|
233
|
+
## API reference
|
|
400
234
|
|
|
401
|
-
|
|
402
|
-
pnpm format
|
|
235
|
+
### Configuration options
|
|
403
236
|
|
|
404
|
-
|
|
405
|
-
|
|
237
|
+
| Option | Type | Default | Description |
|
|
238
|
+
| ------------- | -------------------------- | -------------------------- | ---------------------------- |
|
|
239
|
+
| `entry` | `string` | `'src/pages/**/*.{ts,js}'` | Page entry matching rule |
|
|
240
|
+
| `template` | `string` | `'index.html'` | HTML template file |
|
|
241
|
+
| `placeholder` | `string` | `'{{ENTRY_FILE}}'` | Template placeholder |
|
|
242
|
+
| `exclude` | `string[]` | `[]` | Excluded file patterns |
|
|
243
|
+
| `debug` | `boolean` | `false` | Enable debug log |
|
|
244
|
+
| `strategies` | `Record<string, Strategy>` | `{}` | Build strategy configuration |
|
|
245
|
+
| `pageConfigs` | `Function \| Object` | `{}` | Page |
|
|
406
246
|
|
|
407
|
-
|
|
408
|
-
pnpm build
|
|
409
|
-
```
|
|
247
|
+
### Utility functions
|
|
410
248
|
|
|
411
|
-
|
|
249
|
+
```typescript
|
|
250
|
+
import { defineConfig, defineConfigTransform } from 'vite-plugin-multi-page';
|
|
251
|
+
|
|
252
|
+
// Define configuration
|
|
253
|
+
export default defineConfig(context => ({
|
|
254
|
+
// Configuration options
|
|
255
|
+
}));
|
|
412
256
|
|
|
413
|
-
|
|
257
|
+
// Configuration transformation
|
|
258
|
+
const transform = defineConfigTransform((config, context) => {
|
|
259
|
+
// Modify configuration
|
|
260
|
+
return config;
|
|
261
|
+
});
|
|
262
|
+
```
|
|
414
263
|
|
|
415
|
-
##
|
|
264
|
+
## Example project
|
|
416
265
|
|
|
417
|
-
|
|
266
|
+
See [example](./example) directory for a complete example project.
|
|
418
267
|
|
|
419
|
-
##
|
|
268
|
+
## License
|
|
420
269
|
|
|
421
|
-
|
|
422
|
-
- [TypeScript](https://www.typescriptlang.org/)
|
|
423
|
-
- [ESLint](https://eslint.org/)
|
|
424
|
-
- [Prettier](https://prettier.io/)
|
|
270
|
+
MIT License
|