@fchc8/vite-plugin-multi-page 1.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/LICENSE +21 -0
- package/README-EN.md +424 -0
- package/README.md +502 -0
- package/dist/index.d.mts +89 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +441 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +406 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +88 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
default: () => viteMultiPage,
|
|
34
|
+
viteMultiPage: () => viteMultiPage
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(src_exports);
|
|
37
|
+
var path4 = __toESM(require("path"));
|
|
38
|
+
var fs3 = __toESM(require("fs"));
|
|
39
|
+
|
|
40
|
+
// src/utils.ts
|
|
41
|
+
function escapeRegExp(string) {
|
|
42
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
43
|
+
}
|
|
44
|
+
function createLogger(debug) {
|
|
45
|
+
return (...args) => {
|
|
46
|
+
if (debug) {
|
|
47
|
+
console.log("[vite-plugin-multi-page]", ...args);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/dev-server.ts
|
|
53
|
+
var path2 = __toESM(require("path"));
|
|
54
|
+
var fs = __toESM(require("fs"));
|
|
55
|
+
var import_glob = require("glob");
|
|
56
|
+
|
|
57
|
+
// src/file-filter.ts
|
|
58
|
+
var path = __toESM(require("path"));
|
|
59
|
+
function filterEntryFiles(files, entry, exclude, log) {
|
|
60
|
+
const result = [];
|
|
61
|
+
const nameToFile = /* @__PURE__ */ new Map();
|
|
62
|
+
const basePattern = entry.replace(/\/\*\*.*$/, "");
|
|
63
|
+
log("\u57FA\u7840\u76EE\u5F55\u6A21\u5F0F:", basePattern);
|
|
64
|
+
const candidateFiles = [];
|
|
65
|
+
for (const file of files) {
|
|
66
|
+
if (exclude.includes(file)) {
|
|
67
|
+
log(`\u8DF3\u8FC7\u6392\u9664\u6587\u4EF6: ${file}`);
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const relativePath = path.relative(basePattern, file);
|
|
71
|
+
const pathParts = relativePath.split(path.sep);
|
|
72
|
+
log(`\u5904\u7406\u6587\u4EF6: ${file}`);
|
|
73
|
+
log(`\u76F8\u5BF9\u8DEF\u5F84: ${relativePath}`);
|
|
74
|
+
log(`\u8DEF\u5F84\u90E8\u5206: ${pathParts}`);
|
|
75
|
+
if (pathParts.length === 1) {
|
|
76
|
+
const fileName = pathParts[0];
|
|
77
|
+
const name = path.basename(fileName, path.extname(fileName));
|
|
78
|
+
candidateFiles.push({ name, file, priority: 1 });
|
|
79
|
+
log(`\u{1F4C4} \u7B2C\u4E00\u7EA7\u6587\u4EF6: ${file} -> ${name}.html (\u4F18\u5148\u7EA7: 1)`);
|
|
80
|
+
} else if (pathParts.length >= 2) {
|
|
81
|
+
const fileName = path.basename(file, path.extname(file));
|
|
82
|
+
const dirName = pathParts[0];
|
|
83
|
+
if (fileName === "main") {
|
|
84
|
+
candidateFiles.push({ name: dirName, file, priority: 2 });
|
|
85
|
+
log(`\u{1F4C1} \u76EE\u5F55main\u6587\u4EF6: ${file} -> ${dirName}.html (\u4F18\u5148\u7EA7: 2)`);
|
|
86
|
+
} else {
|
|
87
|
+
log(`\u274C \u8DF3\u8FC7\u6587\u4EF6: ${file} (\u4E0D\u662Fmain\u6587\u4EF6)`);
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
log(`\u274C \u8DF3\u8FC7\u6587\u4EF6: ${file} (\u8DEF\u5F84\u5C42\u7EA7\u4E0D\u7B26\u5408)`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for (const candidate of candidateFiles) {
|
|
94
|
+
const existing = nameToFile.get(candidate.name);
|
|
95
|
+
if (!existing) {
|
|
96
|
+
nameToFile.set(candidate.name, candidate.file);
|
|
97
|
+
log(`\u2705 \u6DFB\u52A0\u9875\u9762: ${candidate.name} -> ${candidate.file}`);
|
|
98
|
+
} else {
|
|
99
|
+
const existingCandidate = candidateFiles.find((c) => c.file === existing);
|
|
100
|
+
if (existingCandidate && candidate.priority > existingCandidate.priority) {
|
|
101
|
+
nameToFile.set(candidate.name, candidate.file);
|
|
102
|
+
log(`\u{1F504} \u66FF\u6362\u9875\u9762: ${candidate.name} -> ${candidate.file} (\u66FF\u6362 ${existing})`);
|
|
103
|
+
} else {
|
|
104
|
+
log(`\u26A0\uFE0F \u51B2\u7A81\u8DF3\u8FC7: ${candidate.name} -> ${candidate.file} (\u4FDD\u7559 ${existing})`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
for (const [name, file] of nameToFile.entries()) {
|
|
109
|
+
result.push({ name, file });
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/dev-server.ts
|
|
115
|
+
function configureDevServer(server, options, log) {
|
|
116
|
+
const allFiles = import_glob.glob.sync(options.entry, { cwd: process.cwd() });
|
|
117
|
+
const entryFiles = filterEntryFiles(allFiles, options.entry, options.exclude, log);
|
|
118
|
+
const pageMap = /* @__PURE__ */ new Map();
|
|
119
|
+
entryFiles.forEach(({ name, file }) => {
|
|
120
|
+
pageMap.set(name, file);
|
|
121
|
+
});
|
|
122
|
+
const pageNames = Array.from(pageMap.keys());
|
|
123
|
+
log("Available pages:", pageNames);
|
|
124
|
+
log("Page mapping:", Object.fromEntries(pageMap));
|
|
125
|
+
server.middlewares.use((req, res, next) => {
|
|
126
|
+
var _a;
|
|
127
|
+
const originalUrl = req.url;
|
|
128
|
+
const url = originalUrl == null ? void 0 : originalUrl.split("?")[0];
|
|
129
|
+
if (!url) {
|
|
130
|
+
return next();
|
|
131
|
+
}
|
|
132
|
+
log(`\u5904\u7406\u8BF7\u6C42: ${url}`);
|
|
133
|
+
if (url === "/" && pageNames.length > 0) {
|
|
134
|
+
const defaultPage = pageNames.includes("index") ? "index" : pageNames[0];
|
|
135
|
+
log(`\u6839\u8DEF\u5F84\u91CD\u5B9A\u5411\u5230: ${defaultPage}`);
|
|
136
|
+
req.url = `/${defaultPage}.html`;
|
|
137
|
+
}
|
|
138
|
+
const finalUrl = (_a = req.url) == null ? void 0 : _a.split("?")[0];
|
|
139
|
+
const pageMatch = finalUrl == null ? void 0 : finalUrl.match(/^\/([^\/\.]+)(\.html)?$/);
|
|
140
|
+
if (pageMatch) {
|
|
141
|
+
const pageName = pageMatch[1];
|
|
142
|
+
log(`\u5339\u914D\u5230\u9875\u9762: ${pageName}`);
|
|
143
|
+
log(`\u53EF\u7528\u9875\u9762\u5217\u8868: ${pageNames.join(", ")}`);
|
|
144
|
+
if (pageMap.has(pageName)) {
|
|
145
|
+
const relativeEntryPath = pageMap.get(pageName);
|
|
146
|
+
const entryPath = path2.resolve(process.cwd(), relativeEntryPath);
|
|
147
|
+
log(`\u9875\u9762 ${pageName} \u5BF9\u5E94\u6587\u4EF6: ${relativeEntryPath}`);
|
|
148
|
+
if (fs.existsSync(entryPath)) {
|
|
149
|
+
log(`\u627E\u5230\u5165\u53E3\u6587\u4EF6: ${entryPath}`);
|
|
150
|
+
const templatePath = path2.resolve(process.cwd(), options.template);
|
|
151
|
+
if (fs.existsSync(templatePath)) {
|
|
152
|
+
let html = fs.readFileSync(templatePath, "utf-8");
|
|
153
|
+
log(`\u8BFB\u53D6\u6A21\u677F\u6587\u4EF6: ${templatePath}`);
|
|
154
|
+
log(`\u6A21\u677F\u5185\u5BB9\u5305\u542B\u5360\u4F4D\u7B26: ${html.includes(options.placeholder)}`);
|
|
155
|
+
if (!html.includes(options.placeholder)) {
|
|
156
|
+
console.warn(
|
|
157
|
+
`[vite-plugin-multi-page] \u6A21\u677F\u6587\u4EF6\u4E2D\u6CA1\u6709\u627E\u5230\u5360\u4F4D\u7B26: ${options.placeholder}`
|
|
158
|
+
);
|
|
159
|
+
return next();
|
|
160
|
+
}
|
|
161
|
+
const entryFile = `/${relativeEntryPath}`;
|
|
162
|
+
html = html.replace(new RegExp(escapeRegExp(options.placeholder), "g"), entryFile);
|
|
163
|
+
log(`\u5360\u4F4D\u7B26 ${options.placeholder} \u66FF\u6362\u4E3A: ${entryFile}`);
|
|
164
|
+
log(`\u66FF\u6362\u540E\u5305\u542B\u5360\u4F4D\u7B26: ${html.includes(options.placeholder)}`);
|
|
165
|
+
res.setHeader("Content-Type", "text/html");
|
|
166
|
+
res.end(html);
|
|
167
|
+
return;
|
|
168
|
+
} else {
|
|
169
|
+
log(`\u6A21\u677F\u6587\u4EF6\u4E0D\u5B58\u5728: ${templatePath}`);
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
log(`\u5165\u53E3\u6587\u4EF6\u4E0D\u5B58\u5728: ${entryPath}`);
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
log(`\u9875\u9762 ${pageName} \u4E0D\u5728\u53EF\u7528\u5217\u8868\u4E2D`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
next();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/build-config.ts
|
|
183
|
+
var path3 = __toESM(require("path"));
|
|
184
|
+
var fs2 = __toESM(require("fs"));
|
|
185
|
+
var import_glob2 = require("glob");
|
|
186
|
+
function simpleMatch(pattern, str) {
|
|
187
|
+
const regexPattern = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".");
|
|
188
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
189
|
+
return regex.test(str);
|
|
190
|
+
}
|
|
191
|
+
function createBuildConfig(config, options, log, tempFiles, pageMapping) {
|
|
192
|
+
var _a, _b, _c;
|
|
193
|
+
const allFiles = import_glob2.glob.sync(options.entry, { cwd: process.cwd() });
|
|
194
|
+
const entryFiles = filterEntryFiles(allFiles, options.entry, options.exclude, log);
|
|
195
|
+
if (entryFiles.length === 0) {
|
|
196
|
+
console.warn("[vite-plugin-multi-page] No entry files found matching pattern:", options.entry);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
log("\u626B\u63CF\u5230\u7684\u6240\u6709\u6587\u4EF6:", allFiles);
|
|
200
|
+
log("\u8FC7\u6EE4\u540E\u7684\u5165\u53E3\u6587\u4EF6:", entryFiles);
|
|
201
|
+
const existingTempFiles = import_glob2.glob.sync("temp-*.html", { cwd: process.cwd() });
|
|
202
|
+
existingTempFiles.forEach((file) => {
|
|
203
|
+
const fullPath = path3.resolve(process.cwd(), file);
|
|
204
|
+
if (fs2.existsSync(fullPath)) {
|
|
205
|
+
fs2.unlinkSync(fullPath);
|
|
206
|
+
log(`\u6E05\u7406\u65E7\u7684\u4E34\u65F6\u6587\u4EF6: ${file}`);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
const input = {};
|
|
210
|
+
tempFiles.length = 0;
|
|
211
|
+
pageMapping.clear();
|
|
212
|
+
const strategyGroups = {};
|
|
213
|
+
const defaultStrategy = "default";
|
|
214
|
+
entryFiles.forEach((entryFile) => {
|
|
215
|
+
const { name, file } = entryFile;
|
|
216
|
+
const pageConfig = getPageConfig(
|
|
217
|
+
options.pageConfigs,
|
|
218
|
+
{
|
|
219
|
+
pageName: name,
|
|
220
|
+
filePath: file,
|
|
221
|
+
relativePath: path3.relative(process.cwd(), file),
|
|
222
|
+
strategy: void 0,
|
|
223
|
+
isMatched: false
|
|
224
|
+
},
|
|
225
|
+
log
|
|
226
|
+
);
|
|
227
|
+
const strategy = (pageConfig == null ? void 0 : pageConfig.strategy) || defaultStrategy;
|
|
228
|
+
if (!strategyGroups[strategy]) {
|
|
229
|
+
strategyGroups[strategy] = [];
|
|
230
|
+
}
|
|
231
|
+
strategyGroups[strategy].push(entryFile);
|
|
232
|
+
const templatePath = (pageConfig == null ? void 0 : pageConfig.template) ? path3.resolve(process.cwd(), pageConfig.template) : path3.resolve(process.cwd(), options.template);
|
|
233
|
+
const tempHtmlPath = path3.resolve(process.cwd(), `temp-${name}.html`);
|
|
234
|
+
if (fs2.existsSync(templatePath)) {
|
|
235
|
+
let html = fs2.readFileSync(templatePath, "utf-8");
|
|
236
|
+
html = html.replace(new RegExp(escapeRegExp(options.placeholder), "g"), `/${file}`);
|
|
237
|
+
fs2.writeFileSync(tempHtmlPath, html);
|
|
238
|
+
tempFiles.push(tempHtmlPath);
|
|
239
|
+
input[name] = tempHtmlPath;
|
|
240
|
+
pageMapping.set(`temp-${name}.html`, `${name}.html`);
|
|
241
|
+
log(`\u521B\u5EFA\u4E34\u65F6\u6587\u4EF6: temp-${name}.html -> ${name}.html (\u7B56\u7565: ${strategy})`);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
log("Build input configuration:", input);
|
|
245
|
+
log("Strategy groups:", Object.keys(strategyGroups));
|
|
246
|
+
config.build = config.build || {};
|
|
247
|
+
config.build.rollupOptions = config.build.rollupOptions || {};
|
|
248
|
+
config.build.rollupOptions.input = input;
|
|
249
|
+
const defaultStrategyConfig = (_a = options.buildStrategies) == null ? void 0 : _a[defaultStrategy];
|
|
250
|
+
if (defaultStrategyConfig) {
|
|
251
|
+
applyBuildStrategy(config, defaultStrategyConfig, log);
|
|
252
|
+
}
|
|
253
|
+
const strategyKeys = Object.keys(strategyGroups);
|
|
254
|
+
if (strategyKeys.length === 1 && strategyKeys[0] !== defaultStrategy) {
|
|
255
|
+
const singleStrategy = (_b = options.buildStrategies) == null ? void 0 : _b[strategyKeys[0]];
|
|
256
|
+
if (singleStrategy) {
|
|
257
|
+
applyBuildStrategy(config, singleStrategy, log);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (strategyKeys.length > 1 || strategyKeys.length === 1 && strategyKeys[0] !== defaultStrategy && ((_c = options.buildStrategies) == null ? void 0 : _c[strategyKeys[0]])) {
|
|
261
|
+
log("\u68C0\u6D4B\u5230\u591A\u6784\u5EFA\u7B56\u7565\uFF0C\u5C06\u521B\u5EFA\u7B56\u7565\u6620\u5C04");
|
|
262
|
+
config.__multiPageStrategies = {
|
|
263
|
+
groups: strategyGroups,
|
|
264
|
+
strategies: options.buildStrategies,
|
|
265
|
+
pageConfigs: options.pageConfigs
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function getPageConfig(pageConfigs, context, log) {
|
|
270
|
+
if (!pageConfigs)
|
|
271
|
+
return null;
|
|
272
|
+
if (typeof pageConfigs === "function") {
|
|
273
|
+
const result = pageConfigs(context);
|
|
274
|
+
if (result) {
|
|
275
|
+
log(`\u51FD\u6570\u914D\u7F6E\u5339\u914D\u9875\u9762 ${context.pageName}:`, result);
|
|
276
|
+
}
|
|
277
|
+
return result;
|
|
278
|
+
}
|
|
279
|
+
for (const [key, config] of Object.entries(pageConfigs)) {
|
|
280
|
+
if (key === context.pageName) {
|
|
281
|
+
log(`\u7CBE\u786E\u5339\u914D\u9875\u9762 ${context.pageName}:`, config);
|
|
282
|
+
return config;
|
|
283
|
+
}
|
|
284
|
+
if (config.match) {
|
|
285
|
+
const patterns = Array.isArray(config.match) ? config.match : [config.match];
|
|
286
|
+
const isMatched = patterns.some(
|
|
287
|
+
(pattern) => simpleMatch(pattern, context.pageName) || simpleMatch(pattern, context.relativePath) || simpleMatch(pattern, context.filePath)
|
|
288
|
+
);
|
|
289
|
+
if (isMatched) {
|
|
290
|
+
log(`\u6A21\u5F0F\u5339\u914D\u9875\u9762 ${context.pageName} (\u6A21\u5F0F: ${config.match}):`, config);
|
|
291
|
+
return { ...config, match: void 0 };
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (simpleMatch(key, context.pageName)) {
|
|
295
|
+
log(`Glob\u5339\u914D\u9875\u9762 ${context.pageName} (\u6A21\u5F0F: ${key}):`, config);
|
|
296
|
+
return config;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
function applyBuildStrategy(config, strategy, log) {
|
|
302
|
+
log("\u5E94\u7528\u6784\u5EFA\u7B56\u7565:", strategy);
|
|
303
|
+
if (strategy.viteConfig) {
|
|
304
|
+
const { build: viteBuild, ...otherViteConfig } = strategy.viteConfig;
|
|
305
|
+
Object.keys(otherViteConfig).forEach((key) => {
|
|
306
|
+
if (key !== "plugins") {
|
|
307
|
+
const configKey = key;
|
|
308
|
+
const viteConfigValue = otherViteConfig[key];
|
|
309
|
+
if (viteConfigValue && typeof viteConfigValue === "object") {
|
|
310
|
+
config[configKey] = {
|
|
311
|
+
...config[configKey] || {},
|
|
312
|
+
...viteConfigValue
|
|
313
|
+
};
|
|
314
|
+
} else {
|
|
315
|
+
config[configKey] = viteConfigValue;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
if (viteBuild) {
|
|
320
|
+
config.build = {
|
|
321
|
+
...config.build,
|
|
322
|
+
...viteBuild
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (strategy.output) {
|
|
327
|
+
config.build.rollupOptions.output = {
|
|
328
|
+
...config.build.rollupOptions.output,
|
|
329
|
+
...strategy.output
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
if (strategy.build) {
|
|
333
|
+
config.build = {
|
|
334
|
+
...config.build,
|
|
335
|
+
...strategy.build
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
if (strategy.define) {
|
|
339
|
+
config.define = {
|
|
340
|
+
...config.define,
|
|
341
|
+
...strategy.define
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
if (strategy.alias) {
|
|
345
|
+
config.resolve = config.resolve || {};
|
|
346
|
+
config.resolve.alias = {
|
|
347
|
+
...config.resolve.alias,
|
|
348
|
+
...strategy.alias
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
if (strategy.server) {
|
|
352
|
+
config.server = {
|
|
353
|
+
...config.server,
|
|
354
|
+
...strategy.server
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
if (strategy.css) {
|
|
358
|
+
config.css = {
|
|
359
|
+
...config.css,
|
|
360
|
+
...strategy.css
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
if (strategy.optimizeDeps) {
|
|
364
|
+
config.optimizeDeps = {
|
|
365
|
+
...config.optimizeDeps,
|
|
366
|
+
...strategy.optimizeDeps
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
function createDevConfig(options, log) {
|
|
371
|
+
const allFiles = import_glob2.glob.sync(options.entry, { cwd: process.cwd() });
|
|
372
|
+
const entryFiles = filterEntryFiles(allFiles, options.entry, options.exclude, log);
|
|
373
|
+
const input = {};
|
|
374
|
+
entryFiles.forEach(({ name, file }) => {
|
|
375
|
+
input[name] = path3.resolve(process.cwd(), file);
|
|
376
|
+
});
|
|
377
|
+
log("Dev input configuration:", input);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// src/index.ts
|
|
381
|
+
function viteMultiPage(options = {}) {
|
|
382
|
+
const {
|
|
383
|
+
entry = "src/**/*.{ts,js}",
|
|
384
|
+
template = "index.html",
|
|
385
|
+
exclude = ["src/main.ts", "src/vite-env.d.ts"],
|
|
386
|
+
placeholder = "{{ENTRY_FILE}}",
|
|
387
|
+
debug = false,
|
|
388
|
+
buildStrategies,
|
|
389
|
+
pageConfigs
|
|
390
|
+
} = options;
|
|
391
|
+
const log = createLogger(debug);
|
|
392
|
+
let tempFiles = [];
|
|
393
|
+
const pageMapping = /* @__PURE__ */ new Map();
|
|
394
|
+
return {
|
|
395
|
+
name: "vite-plugin-multi-page",
|
|
396
|
+
config(config, { command }) {
|
|
397
|
+
if (command === "build") {
|
|
398
|
+
createBuildConfig(
|
|
399
|
+
config,
|
|
400
|
+
{ entry, exclude, template, placeholder, buildStrategies, pageConfigs },
|
|
401
|
+
log,
|
|
402
|
+
tempFiles,
|
|
403
|
+
pageMapping
|
|
404
|
+
);
|
|
405
|
+
} else {
|
|
406
|
+
createDevConfig({ entry, exclude }, log);
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
configureServer(server) {
|
|
410
|
+
configureDevServer(server, { entry, exclude, template, placeholder }, log);
|
|
411
|
+
},
|
|
412
|
+
generateBundle() {
|
|
413
|
+
},
|
|
414
|
+
writeBundle(options2) {
|
|
415
|
+
Array.from(pageMapping.entries()).forEach(([tempName, targetName]) => {
|
|
416
|
+
const tempPath = path4.resolve(options2.dir || "dist", tempName);
|
|
417
|
+
const targetPath = path4.resolve(options2.dir || "dist", targetName);
|
|
418
|
+
if (fs3.existsSync(tempPath)) {
|
|
419
|
+
fs3.renameSync(tempPath, targetPath);
|
|
420
|
+
log(`\u91CD\u547D\u540DHTML\u6587\u4EF6: ${tempName} -> ${targetName}`);
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
},
|
|
424
|
+
closeBundle() {
|
|
425
|
+
tempFiles.forEach((filePath) => {
|
|
426
|
+
if (fs3.existsSync(filePath)) {
|
|
427
|
+
fs3.unlinkSync(filePath);
|
|
428
|
+
const fileName = path4.basename(filePath);
|
|
429
|
+
log(`\u6E05\u7406\u4E34\u65F6\u6587\u4EF6: ${fileName}`);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
tempFiles = [];
|
|
433
|
+
pageMapping.clear();
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
438
|
+
0 && (module.exports = {
|
|
439
|
+
viteMultiPage
|
|
440
|
+
});
|
|
441
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/dev-server.ts","../src/file-filter.ts","../src/build-config.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport * as path from 'node:path';\nimport * as fs from 'node:fs';\nimport type { MultiPageOptions } from './types';\nimport { createLogger } from './utils';\nimport { configureDevServer } from './dev-server';\nimport { createBuildConfig, createDevConfig } from './build-config';\n\nexport type { MultiPageOptions };\n\nexport default function viteMultiPage(options: MultiPageOptions = {}): Plugin {\n const {\n entry = 'src/**/*.{ts,js}',\n template = 'index.html',\n exclude = ['src/main.ts', 'src/vite-env.d.ts'],\n placeholder = '{{ENTRY_FILE}}',\n debug = false,\n buildStrategies,\n pageConfigs,\n } = options;\n\n const log = createLogger(debug);\n let tempFiles: string[] = [];\n const pageMapping: Map<string, string> = new Map();\n\n return {\n name: 'vite-plugin-multi-page',\n\n config(config: any, { command }: { command: string }) {\n if (command === 'build') {\n createBuildConfig(\n config,\n { entry, exclude, template, placeholder, buildStrategies, pageConfigs },\n log,\n tempFiles,\n pageMapping\n );\n } else {\n createDevConfig({ entry, exclude }, log);\n }\n },\n\n configureServer(server) {\n configureDevServer(server, { entry, exclude, template, placeholder }, log);\n },\n\n generateBundle() {\n // 用于处理JS/CSS资源,HTML在writeBundle中处理\n },\n\n writeBundle(options: any) {\n Array.from(pageMapping.entries()).forEach(([tempName, targetName]) => {\n const tempPath = path.resolve(options.dir || 'dist', tempName);\n const targetPath = path.resolve(options.dir || 'dist', targetName);\n\n if (fs.existsSync(tempPath)) {\n fs.renameSync(tempPath, targetPath);\n log(`重命名HTML文件: ${tempName} -> ${targetName}`);\n }\n });\n },\n\n closeBundle() {\n tempFiles.forEach(filePath => {\n if (fs.existsSync(filePath)) {\n fs.unlinkSync(filePath);\n const fileName = path.basename(filePath);\n log(`清理临时文件: ${fileName}`);\n }\n });\n tempFiles = [];\n pageMapping.clear();\n },\n };\n}\n\nexport { viteMultiPage };\n","export function escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nexport function createLogger(debug: boolean) {\n return (...args: any[]) => {\n if (debug) {\n console.log('[vite-plugin-multi-page]', ...args);\n }\n };\n}\n","import type { ViteDevServer } from 'vite';\nimport * as path from 'node:path';\nimport * as fs from 'node:fs';\nimport { glob } from 'glob';\nimport { filterEntryFiles } from './file-filter';\nimport { escapeRegExp } from './utils';\n\nexport function configureDevServer(\n server: ViteDevServer,\n options: {\n entry: string;\n exclude: string[];\n template: string;\n placeholder: string;\n },\n log: (...args: any[]) => void\n) {\n const allFiles = glob.sync(options.entry, { cwd: process.cwd() });\n const entryFiles = filterEntryFiles(allFiles, options.entry, options.exclude, log);\n\n const pageMap = new Map<string, string>();\n entryFiles.forEach(({ name, file }) => {\n pageMap.set(name, file);\n });\n\n const pageNames = Array.from(pageMap.keys());\n log('Available pages:', pageNames);\n log('Page mapping:', Object.fromEntries(pageMap));\n\n server.middlewares.use((req: any, res: any, next: any) => {\n const originalUrl = req.url;\n const url = originalUrl?.split('?')[0];\n\n if (!url) {\n return next();\n }\n\n log(`处理请求: ${url}`);\n\n if (url === '/' && pageNames.length > 0) {\n const defaultPage = pageNames.includes('index') ? 'index' : pageNames[0];\n log(`根路径重定向到: ${defaultPage}`);\n req.url = `/${defaultPage}.html`;\n }\n\n const finalUrl = req.url?.split('?')[0];\n // eslint-disable-next-line no-useless-escape\n const pageMatch = finalUrl?.match(/^\\/([^\\/\\.]+)(\\.html)?$/);\n\n if (pageMatch) {\n const pageName = pageMatch[1];\n\n log(`匹配到页面: ${pageName}`);\n log(`可用页面列表: ${pageNames.join(', ')}`);\n\n if (pageMap.has(pageName)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const relativeEntryPath = pageMap.get(pageName)!;\n const entryPath = path.resolve(process.cwd(), relativeEntryPath);\n\n log(`页面 ${pageName} 对应文件: ${relativeEntryPath}`);\n\n if (fs.existsSync(entryPath)) {\n log(`找到入口文件: ${entryPath}`);\n\n const templatePath = path.resolve(process.cwd(), options.template);\n\n if (fs.existsSync(templatePath)) {\n let html = fs.readFileSync(templatePath, 'utf-8');\n\n log(`读取模板文件: ${templatePath}`);\n log(`模板内容包含占位符: ${html.includes(options.placeholder)}`);\n\n if (!html.includes(options.placeholder)) {\n console.warn(\n `[vite-plugin-multi-page] 模板文件中没有找到占位符: ${options.placeholder}`\n );\n return next();\n }\n\n const entryFile = `/${relativeEntryPath}`;\n html = html.replace(new RegExp(escapeRegExp(options.placeholder), 'g'), entryFile);\n\n log(`占位符 ${options.placeholder} 替换为: ${entryFile}`);\n log(`替换后包含占位符: ${html.includes(options.placeholder)}`);\n\n res.setHeader('Content-Type', 'text/html');\n res.end(html);\n return;\n } else {\n log(`模板文件不存在: ${templatePath}`);\n }\n } else {\n log(`入口文件不存在: ${entryPath}`);\n }\n } else {\n log(`页面 ${pageName} 不在可用列表中`);\n }\n }\n\n next();\n });\n}\n","import * as path from 'node:path';\nimport type { EntryFile, CandidateFile } from './types';\n\nexport function filterEntryFiles(\n files: string[],\n entry: string,\n exclude: string[],\n log: (...args: any[]) => void\n): EntryFile[] {\n const result: EntryFile[] = [];\n const nameToFile = new Map<string, string>();\n\n const basePattern = entry.replace(/\\/\\*\\*.*$/, '');\n log('基础目录模式:', basePattern);\n\n const candidateFiles: CandidateFile[] = [];\n\n for (const file of files) {\n if (exclude.includes(file)) {\n log(`跳过排除文件: ${file}`);\n continue;\n }\n\n const relativePath = path.relative(basePattern, file);\n const pathParts = relativePath.split(path.sep);\n\n log(`处理文件: ${file}`);\n log(`相对路径: ${relativePath}`);\n log(`路径部分: ${pathParts}`);\n\n if (pathParts.length === 1) {\n const fileName = pathParts[0];\n const name = path.basename(fileName, path.extname(fileName));\n candidateFiles.push({ name, file, priority: 1 });\n log(`📄 第一级文件: ${file} -> ${name}.html (优先级: 1)`);\n } else if (pathParts.length >= 2) {\n const fileName = path.basename(file, path.extname(file));\n const dirName = pathParts[0];\n\n if (fileName === 'main') {\n candidateFiles.push({ name: dirName, file, priority: 2 });\n log(`📁 目录main文件: ${file} -> ${dirName}.html (优先级: 2)`);\n } else {\n log(`❌ 跳过文件: ${file} (不是main文件)`);\n }\n } else {\n log(`❌ 跳过文件: ${file} (路径层级不符合)`);\n }\n }\n\n for (const candidate of candidateFiles) {\n const existing = nameToFile.get(candidate.name);\n\n if (!existing) {\n nameToFile.set(candidate.name, candidate.file);\n log(`✅ 添加页面: ${candidate.name} -> ${candidate.file}`);\n } else {\n const existingCandidate = candidateFiles.find(c => c.file === existing);\n if (existingCandidate && candidate.priority > existingCandidate.priority) {\n nameToFile.set(candidate.name, candidate.file);\n log(`🔄 替换页面: ${candidate.name} -> ${candidate.file} (替换 ${existing})`);\n } else {\n log(`⚠️ 冲突跳过: ${candidate.name} -> ${candidate.file} (保留 ${existing})`);\n }\n }\n }\n\n for (const [name, file] of nameToFile.entries()) {\n result.push({ name, file });\n }\n\n return result;\n}\n","import * as path from 'node:path';\nimport * as fs from 'node:fs';\nimport { glob } from 'glob';\nimport { filterEntryFiles } from './file-filter';\nimport { escapeRegExp } from './utils';\nimport type { BuildStrategy, PageConfig, PageConfigFunction, PageConfigContext } from './types';\n\n// 简单的 glob 模式匹配函数\nfunction simpleMatch(pattern: string, str: string): boolean {\n const regexPattern = pattern\n .replace(/[.+^${}()|[\\]\\\\]/g, '\\\\$&') // 转义特殊字符\n .replace(/\\*/g, '.*') // * 匹配任意字符\n .replace(/\\?/g, '.'); // ? 匹配单个字符\n\n const regex = new RegExp(`^${regexPattern}$`);\n return regex.test(str);\n}\n\nexport function createBuildConfig(\n config: any,\n options: {\n entry: string;\n exclude: string[];\n template: string;\n placeholder: string;\n buildStrategies?: Record<string, BuildStrategy>;\n pageConfigs?: Record<string, PageConfig> | PageConfigFunction;\n },\n log: (...args: any[]) => void,\n tempFiles: string[],\n pageMapping: Map<string, string>\n) {\n const allFiles = glob.sync(options.entry, { cwd: process.cwd() });\n const entryFiles = filterEntryFiles(allFiles, options.entry, options.exclude, log);\n\n if (entryFiles.length === 0) {\n console.warn('[vite-plugin-multi-page] No entry files found matching pattern:', options.entry);\n return;\n }\n\n log('扫描到的所有文件:', allFiles);\n log('过滤后的入口文件:', entryFiles);\n\n // 清理旧的临时文件\n const existingTempFiles = glob.sync('temp-*.html', { cwd: process.cwd() });\n existingTempFiles.forEach(file => {\n const fullPath = path.resolve(process.cwd(), file);\n if (fs.existsSync(fullPath)) {\n fs.unlinkSync(fullPath);\n log(`清理旧的临时文件: ${file}`);\n }\n });\n\n const input: Record<string, string> = {};\n tempFiles.length = 0; // 清空数组\n pageMapping.clear();\n\n // 分组页面按构建策略\n const strategyGroups: Record<string, typeof entryFiles> = {};\n const defaultStrategy = 'default';\n\n entryFiles.forEach(entryFile => {\n const { name, file } = entryFile;\n\n // 获取页面配置\n const pageConfig = getPageConfig(\n options.pageConfigs,\n {\n pageName: name,\n filePath: file,\n relativePath: path.relative(process.cwd(), file),\n strategy: undefined,\n isMatched: false,\n },\n log\n );\n\n const strategy = pageConfig?.strategy || defaultStrategy;\n\n if (!strategyGroups[strategy]) {\n strategyGroups[strategy] = [];\n }\n strategyGroups[strategy].push(entryFile);\n\n // 创建HTML文件\n const templatePath = pageConfig?.template\n ? path.resolve(process.cwd(), pageConfig.template)\n : path.resolve(process.cwd(), options.template);\n\n const tempHtmlPath = path.resolve(process.cwd(), `temp-${name}.html`);\n\n if (fs.existsSync(templatePath)) {\n let html = fs.readFileSync(templatePath, 'utf-8');\n html = html.replace(new RegExp(escapeRegExp(options.placeholder), 'g'), `/${file}`);\n\n fs.writeFileSync(tempHtmlPath, html);\n tempFiles.push(tempHtmlPath);\n\n input[name] = tempHtmlPath;\n pageMapping.set(`temp-${name}.html`, `${name}.html`);\n\n log(`创建临时文件: temp-${name}.html -> ${name}.html (策略: ${strategy})`);\n }\n });\n\n log('Build input configuration:', input);\n log('Strategy groups:', Object.keys(strategyGroups));\n\n // 应用构建策略\n config.build = config.build || {};\n config.build.rollupOptions = config.build.rollupOptions || {};\n config.build.rollupOptions.input = input;\n\n // 应用默认或指定的构建策略\n const defaultStrategyConfig = options.buildStrategies?.[defaultStrategy];\n if (defaultStrategyConfig) {\n applyBuildStrategy(config, defaultStrategyConfig, log);\n }\n\n // 如果只有一个策略组且不是默认策略,应用该策略\n const strategyKeys = Object.keys(strategyGroups);\n if (strategyKeys.length === 1 && strategyKeys[0] !== defaultStrategy) {\n const singleStrategy = options.buildStrategies?.[strategyKeys[0]];\n if (singleStrategy) {\n applyBuildStrategy(config, singleStrategy, log);\n }\n }\n\n // 处理多策略情况(需要多次构建)\n if (\n strategyKeys.length > 1 ||\n (strategyKeys.length === 1 &&\n strategyKeys[0] !== defaultStrategy &&\n options.buildStrategies?.[strategyKeys[0]])\n ) {\n log('检测到多构建策略,将创建策略映射');\n // 在插件实例上存储策略信息,供后续处理\n (config as any).__multiPageStrategies = {\n groups: strategyGroups,\n strategies: options.buildStrategies,\n pageConfigs: options.pageConfigs,\n };\n }\n}\n\nfunction getPageConfig(\n pageConfigs: Record<string, PageConfig> | PageConfigFunction | undefined,\n context: PageConfigContext,\n log: (...args: any[]) => void\n): PageConfig | null {\n if (!pageConfigs) return null;\n\n // 如果是函数,直接调用\n if (typeof pageConfigs === 'function') {\n const result = pageConfigs(context);\n if (result) {\n log(`函数配置匹配页面 ${context.pageName}:`, result);\n }\n return result;\n }\n\n // 对象配置:支持精确匹配和模式匹配\n for (const [key, config] of Object.entries(pageConfigs)) {\n // 精确匹配页面名称\n if (key === context.pageName) {\n log(`精确匹配页面 ${context.pageName}:`, config);\n return config;\n }\n\n // 模式匹配\n if (config.match) {\n const patterns = Array.isArray(config.match) ? config.match : [config.match];\n const isMatched = patterns.some(\n pattern =>\n simpleMatch(pattern, context.pageName) ||\n simpleMatch(pattern, context.relativePath) ||\n simpleMatch(pattern, context.filePath)\n );\n\n if (isMatched) {\n log(`模式匹配页面 ${context.pageName} (模式: ${config.match}):`, config);\n return { ...config, match: undefined }; // 移除 match 属性避免传递给构建配置\n }\n }\n\n // glob 模式匹配页面名称\n if (simpleMatch(key, context.pageName)) {\n log(`Glob匹配页面 ${context.pageName} (模式: ${key}):`, config);\n return config;\n }\n }\n\n return null;\n}\n\nfunction applyBuildStrategy(config: any, strategy: BuildStrategy, log: (...args: any[]) => void) {\n log('应用构建策略:', strategy);\n\n // 应用完整的 Vite 配置\n if (strategy.viteConfig) {\n const { build: viteBuild, ...otherViteConfig } = strategy.viteConfig;\n\n // 合并非构建配置\n Object.keys(otherViteConfig).forEach(key => {\n if (key !== 'plugins') {\n // 跳过 plugins,避免冲突\n const configKey = key as keyof typeof config;\n const viteConfigValue = otherViteConfig[key as keyof typeof otherViteConfig];\n if (viteConfigValue && typeof viteConfigValue === 'object') {\n config[configKey] = {\n ...(config[configKey] || {}),\n ...viteConfigValue,\n };\n } else {\n config[configKey] = viteConfigValue;\n }\n }\n });\n\n // 合并构建配置\n if (viteBuild) {\n config.build = {\n ...config.build,\n ...viteBuild,\n };\n }\n }\n\n // 应用输出配置\n if (strategy.output) {\n config.build.rollupOptions.output = {\n ...config.build.rollupOptions.output,\n ...strategy.output,\n };\n }\n\n // 应用构建配置\n if (strategy.build) {\n config.build = {\n ...config.build,\n ...strategy.build,\n };\n }\n\n // 应用环境变量\n if (strategy.define) {\n config.define = {\n ...config.define,\n ...strategy.define,\n };\n }\n\n // 应用别名配置\n if (strategy.alias) {\n config.resolve = config.resolve || {};\n config.resolve.alias = {\n ...config.resolve.alias,\n ...strategy.alias,\n };\n }\n\n // 应用服务器配置\n if (strategy.server) {\n config.server = {\n ...config.server,\n ...strategy.server,\n };\n }\n\n // 应用 CSS 配置\n if (strategy.css) {\n config.css = {\n ...config.css,\n ...strategy.css,\n };\n }\n\n // 应用优化依赖配置\n if (strategy.optimizeDeps) {\n config.optimizeDeps = {\n ...config.optimizeDeps,\n ...strategy.optimizeDeps,\n };\n }\n}\n\nexport function createDevConfig(\n options: {\n entry: string;\n exclude: string[];\n },\n log: (...args: any[]) => void\n) {\n const allFiles = glob.sync(options.entry, { cwd: process.cwd() });\n const entryFiles = filterEntryFiles(allFiles, options.entry, options.exclude, log);\n\n const input: Record<string, string> = {};\n entryFiles.forEach(({ name, file }) => {\n input[name] = path.resolve(process.cwd(), file);\n });\n log('Dev input configuration:', input);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,QAAsB;AACtB,IAAAC,MAAoB;;;ACFb,SAAS,aAAa,QAAwB;AACnD,SAAO,OAAO,QAAQ,uBA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