@fchc8/vite-plugin-multi-page 1.0.2 → 1.0.4
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 +75 -75
- package/README.md +0 -72
- package/package.json +5 -5
package/README-EN.md
CHANGED
|
@@ -17,11 +17,11 @@ A powerful Vite plugin for building multi-page applications with smart file rout
|
|
|
17
17
|
## 📦 Installation
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
npm install vite-plugin-multi-page
|
|
20
|
+
npm install @fchc8/vite-plugin-multi-page
|
|
21
21
|
# or
|
|
22
|
-
yarn add vite-plugin-multi-page
|
|
22
|
+
yarn add @fchc8/vite-plugin-multi-page
|
|
23
23
|
# or
|
|
24
|
-
pnpm add vite-plugin-multi-page
|
|
24
|
+
pnpm add @fchc8/vite-plugin-multi-page
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## 🚀 Quick Start
|
|
@@ -31,7 +31,7 @@ pnpm add vite-plugin-multi-page
|
|
|
31
31
|
```typescript
|
|
32
32
|
// vite.config.ts
|
|
33
33
|
import { defineConfig } from 'vite';
|
|
34
|
-
import viteMultiPage from 'vite-plugin-multi-page';
|
|
34
|
+
import viteMultiPage from '@fchc8/vite-plugin-multi-page';
|
|
35
35
|
|
|
36
36
|
export default defineConfig({
|
|
37
37
|
plugins: [
|
|
@@ -39,9 +39,9 @@ export default defineConfig({
|
|
|
39
39
|
entry: 'src/pages/**/*.{ts,js}',
|
|
40
40
|
template: 'index.html',
|
|
41
41
|
exclude: ['src/main.ts'],
|
|
42
|
-
debug: true
|
|
43
|
-
})
|
|
44
|
-
]
|
|
42
|
+
debug: true,
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
45
45
|
});
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -68,69 +68,69 @@ project/
|
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
70
|
import { defineConfig } from 'vite';
|
|
71
|
-
import viteMultiPage from 'vite-plugin-multi-page';
|
|
71
|
+
import viteMultiPage from '@fchc8/vite-plugin-multi-page';
|
|
72
72
|
|
|
73
73
|
export default defineConfig({
|
|
74
74
|
plugins: [
|
|
75
75
|
viteMultiPage({
|
|
76
76
|
entry: 'src/pages/**/*.{ts,js}',
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
// Define build strategies
|
|
79
79
|
buildStrategies: {
|
|
80
80
|
// Modern browser strategy
|
|
81
81
|
default: {
|
|
82
82
|
viteConfig: {
|
|
83
83
|
define: {
|
|
84
|
-
'process.env.BUILD_TYPE': '"modern"'
|
|
85
|
-
}
|
|
84
|
+
'process.env.BUILD_TYPE': '"modern"',
|
|
85
|
+
},
|
|
86
86
|
},
|
|
87
87
|
output: {
|
|
88
88
|
format: 'es',
|
|
89
|
-
entryFileNames: 'assets/[name]-[hash].js'
|
|
89
|
+
entryFileNames: 'assets/[name]-[hash].js',
|
|
90
90
|
},
|
|
91
91
|
build: {
|
|
92
92
|
target: 'es2015',
|
|
93
93
|
minify: 'esbuild',
|
|
94
|
-
sourcemap: true
|
|
95
|
-
}
|
|
94
|
+
sourcemap: true,
|
|
95
|
+
},
|
|
96
96
|
},
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
// Legacy compatibility strategy
|
|
99
99
|
legacy: {
|
|
100
100
|
viteConfig: {
|
|
101
101
|
define: {
|
|
102
|
-
'process.env.BUILD_TYPE': '"legacy"'
|
|
103
|
-
}
|
|
102
|
+
'process.env.BUILD_TYPE': '"legacy"',
|
|
103
|
+
},
|
|
104
104
|
},
|
|
105
105
|
output: {
|
|
106
106
|
format: 'iife',
|
|
107
|
-
entryFileNames: 'legacy/[name].js'
|
|
107
|
+
entryFileNames: 'legacy/[name].js',
|
|
108
108
|
},
|
|
109
109
|
build: {
|
|
110
110
|
target: 'es5',
|
|
111
111
|
minify: 'terser',
|
|
112
|
-
sourcemap: false
|
|
113
|
-
}
|
|
112
|
+
sourcemap: false,
|
|
113
|
+
},
|
|
114
114
|
},
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
// Mobile optimization strategy
|
|
117
117
|
mobile: {
|
|
118
118
|
viteConfig: {
|
|
119
119
|
css: {
|
|
120
|
-
devSourcemap: true
|
|
120
|
+
devSourcemap: true,
|
|
121
121
|
},
|
|
122
122
|
optimizeDeps: {
|
|
123
|
-
include: ['mobile-utils']
|
|
124
|
-
}
|
|
123
|
+
include: ['mobile-utils'],
|
|
124
|
+
},
|
|
125
125
|
},
|
|
126
126
|
build: {
|
|
127
127
|
target: 'es2018',
|
|
128
|
-
chunkSizeWarningLimit: 300
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
})
|
|
133
|
-
]
|
|
128
|
+
chunkSizeWarningLimit: 300,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
}),
|
|
133
|
+
],
|
|
134
134
|
});
|
|
135
135
|
```
|
|
136
136
|
|
|
@@ -139,39 +139,39 @@ export default defineConfig({
|
|
|
139
139
|
```typescript
|
|
140
140
|
viteMultiPage({
|
|
141
141
|
entry: 'src/pages/**/*.{ts,js}',
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
// Use function for dynamic configuration
|
|
144
|
-
pageConfigs:
|
|
144
|
+
pageConfigs: context => {
|
|
145
145
|
const { pageName, filePath, relativePath } = context;
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
// Admin pages
|
|
148
148
|
if (pageName.startsWith('admin')) {
|
|
149
149
|
return {
|
|
150
150
|
strategy: 'default',
|
|
151
151
|
template: 'admin.html',
|
|
152
152
|
define: {
|
|
153
|
-
'process.env.API_BASE': '"https://admin-api.example.com"'
|
|
154
|
-
}
|
|
153
|
+
'process.env.API_BASE': '"https://admin-api.example.com"',
|
|
154
|
+
},
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
// Mobile pages
|
|
159
159
|
if (relativePath.includes('/mobile/')) {
|
|
160
160
|
return {
|
|
161
161
|
strategy: 'mobile',
|
|
162
162
|
template: 'mobile.html',
|
|
163
163
|
define: {
|
|
164
|
-
'process.env.API_BASE': '"https://mobile-api.example.com"'
|
|
165
|
-
}
|
|
164
|
+
'process.env.API_BASE': '"https://mobile-api.example.com"',
|
|
165
|
+
},
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
|
-
|
|
168
|
+
|
|
169
169
|
// Default configuration
|
|
170
170
|
return {
|
|
171
|
-
strategy: 'default'
|
|
171
|
+
strategy: 'default',
|
|
172
172
|
};
|
|
173
|
-
}
|
|
174
|
-
})
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
175
|
```
|
|
176
176
|
|
|
177
177
|
### Object Configuration with Pattern Matching
|
|
@@ -179,43 +179,43 @@ viteMultiPage({
|
|
|
179
179
|
```typescript
|
|
180
180
|
viteMultiPage({
|
|
181
181
|
entry: 'src/pages/**/*.{ts,js}',
|
|
182
|
-
|
|
182
|
+
|
|
183
183
|
pageConfigs: {
|
|
184
184
|
// Exact match
|
|
185
|
-
|
|
185
|
+
home: {
|
|
186
186
|
strategy: 'default',
|
|
187
|
-
template: 'home.html'
|
|
187
|
+
template: 'home.html',
|
|
188
188
|
},
|
|
189
|
-
|
|
189
|
+
|
|
190
190
|
// Wildcard match
|
|
191
191
|
'admin*': {
|
|
192
192
|
strategy: 'default',
|
|
193
|
-
template: 'admin.html'
|
|
193
|
+
template: 'admin.html',
|
|
194
194
|
},
|
|
195
|
-
|
|
195
|
+
|
|
196
196
|
// Pattern match
|
|
197
197
|
'mobile-app': {
|
|
198
198
|
strategy: 'mobile',
|
|
199
199
|
match: ['**/mobile/**', '*mobile*'],
|
|
200
|
-
template: 'mobile.html'
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
})
|
|
200
|
+
template: 'mobile.html',
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
## 📋 Configuration Options
|
|
207
207
|
|
|
208
208
|
### MultiPageOptions
|
|
209
209
|
|
|
210
|
-
| Option
|
|
211
|
-
|
|
212
|
-
| `entry`
|
|
213
|
-
| `template`
|
|
214
|
-
| `exclude`
|
|
215
|
-
| `placeholder`
|
|
216
|
-
| `debug`
|
|
217
|
-
| `buildStrategies` | `Record<string, BuildStrategy>`
|
|
218
|
-
| `pageConfigs`
|
|
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 |
|
|
219
219
|
|
|
220
220
|
### BuildStrategy
|
|
221
221
|
|
|
@@ -225,7 +225,7 @@ interface BuildStrategy {
|
|
|
225
225
|
viteConfig?: Omit<UserConfig, 'plugins' | 'build'> & {
|
|
226
226
|
build?: BuildOptions;
|
|
227
227
|
};
|
|
228
|
-
|
|
228
|
+
|
|
229
229
|
// Output configuration
|
|
230
230
|
output?: {
|
|
231
231
|
format?: 'es' | 'cjs' | 'umd' | 'iife';
|
|
@@ -236,7 +236,7 @@ interface BuildStrategy {
|
|
|
236
236
|
globals?: Record<string, string>;
|
|
237
237
|
external?: string | string[] | ((id: string) => boolean);
|
|
238
238
|
};
|
|
239
|
-
|
|
239
|
+
|
|
240
240
|
// Build configuration
|
|
241
241
|
build?: {
|
|
242
242
|
target?: string | string[];
|
|
@@ -248,19 +248,19 @@ interface BuildStrategy {
|
|
|
248
248
|
rollupOptions?: any;
|
|
249
249
|
// ... more Vite build options
|
|
250
250
|
};
|
|
251
|
-
|
|
251
|
+
|
|
252
252
|
// Environment variables
|
|
253
253
|
define?: Record<string, any>;
|
|
254
|
-
|
|
254
|
+
|
|
255
255
|
// Alias configuration
|
|
256
256
|
alias?: Record<string, string>;
|
|
257
|
-
|
|
257
|
+
|
|
258
258
|
// Server configuration
|
|
259
259
|
server?: ServerOptions;
|
|
260
|
-
|
|
260
|
+
|
|
261
261
|
// CSS configuration
|
|
262
262
|
css?: CSSOptions;
|
|
263
|
-
|
|
263
|
+
|
|
264
264
|
// Dependency optimization
|
|
265
265
|
optimizeDeps?: DepOptimizationOptions;
|
|
266
266
|
}
|
|
@@ -270,13 +270,13 @@ interface BuildStrategy {
|
|
|
270
270
|
|
|
271
271
|
```typescript
|
|
272
272
|
interface PageConfig {
|
|
273
|
-
strategy?: string;
|
|
274
|
-
template?: string;
|
|
275
|
-
exclude?: string[];
|
|
273
|
+
strategy?: string; // Build strategy to use
|
|
274
|
+
template?: string; // Page template
|
|
275
|
+
exclude?: string[]; // Exclude rules
|
|
276
276
|
define?: Record<string, any>; // Environment variables
|
|
277
277
|
alias?: Record<string, string>; // Aliases
|
|
278
278
|
build?: Partial<BuildStrategy['build']>; // Build configuration
|
|
279
|
-
match?: string | string[];
|
|
279
|
+
match?: string | string[]; // Match patterns
|
|
280
280
|
}
|
|
281
281
|
```
|
|
282
282
|
|
|
@@ -295,7 +295,7 @@ buildStrategies: {
|
|
|
295
295
|
sourcemap: true
|
|
296
296
|
}
|
|
297
297
|
},
|
|
298
|
-
|
|
298
|
+
|
|
299
299
|
public: {
|
|
300
300
|
viteConfig: {
|
|
301
301
|
define: { 'process.env.APP_TYPE': '"public"' }
|
|
@@ -386,7 +386,7 @@ After building, visit these pages:
|
|
|
386
386
|
|
|
387
387
|
```bash
|
|
388
388
|
# Clone the project
|
|
389
|
-
git clone
|
|
389
|
+
git clone https://github.com/fchc7/vite-plugin-multi-page.git
|
|
390
390
|
cd vite-plugin-multi-page
|
|
391
391
|
|
|
392
392
|
# Install dependencies
|
|
@@ -421,4 +421,4 @@ MIT License
|
|
|
421
421
|
- [Vite Official Documentation](https://vitejs.dev/)
|
|
422
422
|
- [TypeScript](https://www.typescriptlang.org/)
|
|
423
423
|
- [ESLint](https://eslint.org/)
|
|
424
|
-
- [Prettier](https://prettier.io/)
|
|
424
|
+
- [Prettier](https://prettier.io/)
|
package/README.md
CHANGED
|
@@ -403,78 +403,6 @@ pnpm lint
|
|
|
403
403
|
pnpm build
|
|
404
404
|
```
|
|
405
405
|
|
|
406
|
-
## 🔄 Git Flow 工作流
|
|
407
|
-
|
|
408
|
-
我们使用 Git Flow 进行版本管理和发布:
|
|
409
|
-
|
|
410
|
-
### 功能开发
|
|
411
|
-
|
|
412
|
-
```bash
|
|
413
|
-
# 开始新功能
|
|
414
|
-
npm run git:feature start mobile-support
|
|
415
|
-
|
|
416
|
-
# 完成功能开发
|
|
417
|
-
npm run git:feature finish mobile-support
|
|
418
|
-
```
|
|
419
|
-
|
|
420
|
-
### 版本发布
|
|
421
|
-
|
|
422
|
-
```bash
|
|
423
|
-
# 开始发布准备
|
|
424
|
-
npm run git:release start 1.1.0
|
|
425
|
-
|
|
426
|
-
# 完成发布
|
|
427
|
-
npm run git:release finish 1.1.0
|
|
428
|
-
|
|
429
|
-
# 发布到 npm
|
|
430
|
-
npm run git:release publish minor
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
### 紧急修复
|
|
434
|
-
|
|
435
|
-
```bash
|
|
436
|
-
# 开始紧急修复
|
|
437
|
-
npm run git:hotfix start 1.0.1
|
|
438
|
-
|
|
439
|
-
# 完成修复
|
|
440
|
-
npm run git:hotfix finish 1.0.1
|
|
441
|
-
```
|
|
442
|
-
|
|
443
|
-
## 📦 发布流程
|
|
444
|
-
|
|
445
|
-
### 发布前检查
|
|
446
|
-
|
|
447
|
-
```bash
|
|
448
|
-
# 运行完整检查
|
|
449
|
-
npm run pre-release
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
### 直接发布
|
|
453
|
-
|
|
454
|
-
```bash
|
|
455
|
-
# 补丁版本 (1.0.0 -> 1.0.1)
|
|
456
|
-
npm run release:patch
|
|
457
|
-
|
|
458
|
-
# 次要版本 (1.0.0 -> 1.1.0)
|
|
459
|
-
npm run release:minor
|
|
460
|
-
|
|
461
|
-
# 主要版本 (1.0.0 -> 2.0.0)
|
|
462
|
-
npm run release:major
|
|
463
|
-
|
|
464
|
-
# 预发布版本
|
|
465
|
-
npm run release:beta # Beta 版本
|
|
466
|
-
npm run release:alpha # Alpha 版本
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
### 自动化发布
|
|
470
|
-
|
|
471
|
-
推送标签会自动触发 GitHub Actions 发布:
|
|
472
|
-
|
|
473
|
-
```bash
|
|
474
|
-
git tag v1.1.0
|
|
475
|
-
git push origin v1.1.0
|
|
476
|
-
```
|
|
477
|
-
|
|
478
406
|
## 🤝 贡献
|
|
479
407
|
|
|
480
408
|
欢迎提交 Issue 和 Pull Request!
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fchc8/vite-plugin-multi-page",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "A Vite plugin for building multi-page applications with smart file routing",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -21,15 +21,15 @@
|
|
|
21
21
|
"file-based",
|
|
22
22
|
"typescript"
|
|
23
23
|
],
|
|
24
|
-
"author": "
|
|
24
|
+
"author": "jx.zhu@foxmail.com",
|
|
25
25
|
"license": "MIT",
|
|
26
|
-
"homepage": "https://github.com/
|
|
26
|
+
"homepage": "https://github.com/fchc7/vite-plugin-multi-page#readme",
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|
|
29
|
-
"url": "git+https://github.com/
|
|
29
|
+
"url": "git+https://github.com/fchc7/vite-plugin-multi-page.git"
|
|
30
30
|
},
|
|
31
31
|
"bugs": {
|
|
32
|
-
"url": "https://github.com/
|
|
32
|
+
"url": "https://github.com/fchc7/vite-plugin-multi-page/issues"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsup",
|