@uni-helper/vite-plugin-uni-pages 0.0.7 → 0.1.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.md +76 -42
- package/dist/index.cjs +345 -247
- package/dist/index.d.ts +228 -238
- package/dist/index.mjs +366 -0
- package/package.json +20 -34
- package/README.Zh-CN.md +0 -94
- package/dist/index.cjs.map +0 -1
- package/dist/index.js +0 -261
- package/dist/index.js.map +0 -1
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import MagicString from 'magic-string';
|
|
3
|
+
import chokidar from 'chokidar';
|
|
4
|
+
import { loadConfig } from 'unconfig';
|
|
5
|
+
import Debug from 'debug';
|
|
6
|
+
import { groupBy } from 'lodash-es';
|
|
7
|
+
import fg from 'fast-glob';
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import JSON5 from 'json5';
|
|
10
|
+
import { parse as parse$1 } from 'yaml';
|
|
11
|
+
import { parse } from '@vue/compiler-sfc';
|
|
12
|
+
|
|
13
|
+
function slash(str) {
|
|
14
|
+
return str.replace(/\\/g, "/");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const MODULE_ID_VIRTUAL = "virtual:uni-pages";
|
|
18
|
+
const RESOLVED_MODULE_ID_VIRTUAL = `\0${MODULE_ID_VIRTUAL}`;
|
|
19
|
+
const OUTPUT_NAME = "pages.json";
|
|
20
|
+
const FILE_EXTENSIONS = ["vue", "nvue", "uvue"];
|
|
21
|
+
|
|
22
|
+
function invalidatePagesModule(server) {
|
|
23
|
+
const { moduleGraph } = server;
|
|
24
|
+
const mods = moduleGraph.getModulesByFile(RESOLVED_MODULE_ID_VIRTUAL);
|
|
25
|
+
if (mods) {
|
|
26
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27
|
+
mods.forEach((mod) => {
|
|
28
|
+
moduleGraph.invalidateModule(mod, seen);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const debug = {
|
|
33
|
+
hmr: Debug("vite-plugin-uni-pages:hmr"),
|
|
34
|
+
routeBlock: Debug("vite-plugin-uni-pages:routeBlock"),
|
|
35
|
+
options: Debug("vite-plugin-uni-pages:options"),
|
|
36
|
+
pages: Debug("vite-plugin-uni-pages:pages"),
|
|
37
|
+
error: Debug("vite-plugin-uni-pages:error")
|
|
38
|
+
};
|
|
39
|
+
function extsToGlob(extensions) {
|
|
40
|
+
return extensions.length > 1 ? `{${extensions.join(",")}}` : extensions[0] || "";
|
|
41
|
+
}
|
|
42
|
+
function isTargetFile(path) {
|
|
43
|
+
const ext = path.split(".").pop();
|
|
44
|
+
return FILE_EXTENSIONS.includes(ext);
|
|
45
|
+
}
|
|
46
|
+
function isConfigFile(path) {
|
|
47
|
+
return path.includes("pages.config");
|
|
48
|
+
}
|
|
49
|
+
function mergePageMetaDataArray(pageMetaData) {
|
|
50
|
+
const pageMetaDataObj = groupBy(pageMetaData, "path");
|
|
51
|
+
const result = [];
|
|
52
|
+
for (const path in pageMetaDataObj) {
|
|
53
|
+
const _pageMetaData = pageMetaDataObj[path];
|
|
54
|
+
const options = _pageMetaData[0];
|
|
55
|
+
for (const page of _pageMetaData) {
|
|
56
|
+
options.style = Object.assign(options.style ?? {}, page.style ?? {});
|
|
57
|
+
Object.assign(options, page);
|
|
58
|
+
}
|
|
59
|
+
result.push(options);
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function resolveOptions(userOptions, viteRoot) {
|
|
65
|
+
const {
|
|
66
|
+
mergePages = true,
|
|
67
|
+
dir = "src/pages",
|
|
68
|
+
outDir = "src",
|
|
69
|
+
exclude = ["node_modules", ".git", "**/__*__/**"],
|
|
70
|
+
routeBlockLang = "json5",
|
|
71
|
+
onBeforeLoadUserConfig = () => {
|
|
72
|
+
},
|
|
73
|
+
onAfterLoadUserConfig = () => {
|
|
74
|
+
},
|
|
75
|
+
onBeforeScanPages = () => {
|
|
76
|
+
},
|
|
77
|
+
onAfterScanPages = () => {
|
|
78
|
+
},
|
|
79
|
+
onBeforeMergePageMetaData = () => {
|
|
80
|
+
},
|
|
81
|
+
onAfterMergePageMetaData = () => {
|
|
82
|
+
},
|
|
83
|
+
onBeforeWriteFile = () => {
|
|
84
|
+
},
|
|
85
|
+
onAfterWriteFile = () => {
|
|
86
|
+
}
|
|
87
|
+
} = userOptions;
|
|
88
|
+
const root = viteRoot || slash(process.cwd());
|
|
89
|
+
const resolvedDirs = resolvePageDirs(dir, root, exclude);
|
|
90
|
+
const resolvedOptions = {
|
|
91
|
+
mergePages,
|
|
92
|
+
dirs: resolvedDirs,
|
|
93
|
+
outDir,
|
|
94
|
+
exclude,
|
|
95
|
+
routeBlockLang,
|
|
96
|
+
root,
|
|
97
|
+
onBeforeLoadUserConfig,
|
|
98
|
+
onAfterLoadUserConfig,
|
|
99
|
+
onBeforeScanPages,
|
|
100
|
+
onAfterScanPages,
|
|
101
|
+
onBeforeMergePageMetaData,
|
|
102
|
+
onAfterMergePageMetaData,
|
|
103
|
+
onBeforeWriteFile,
|
|
104
|
+
onAfterWriteFile
|
|
105
|
+
};
|
|
106
|
+
return resolvedOptions;
|
|
107
|
+
}
|
|
108
|
+
function resolvePageDirs(dir, root, exclude) {
|
|
109
|
+
const dirs = fg.sync(slash(dir), {
|
|
110
|
+
ignore: exclude,
|
|
111
|
+
onlyDirectories: true,
|
|
112
|
+
dot: true,
|
|
113
|
+
unique: true,
|
|
114
|
+
cwd: root
|
|
115
|
+
});
|
|
116
|
+
return dirs;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function getPageFiles(path, options) {
|
|
120
|
+
const { exclude } = options;
|
|
121
|
+
const ext = extsToGlob(FILE_EXTENSIONS);
|
|
122
|
+
const files = fg.sync(`**/*.${ext}`, {
|
|
123
|
+
ignore: exclude,
|
|
124
|
+
onlyFiles: true,
|
|
125
|
+
cwd: path
|
|
126
|
+
});
|
|
127
|
+
return files;
|
|
128
|
+
}
|
|
129
|
+
function checkPagesJsonFile(path) {
|
|
130
|
+
if (!fs.existsSync(path))
|
|
131
|
+
writeFileSync(path, JSON.stringify({ pages: [{ path: "" }] }, null, 2));
|
|
132
|
+
}
|
|
133
|
+
function writeFileSync(path, content) {
|
|
134
|
+
fs.writeFileSync(path, content, { encoding: "utf-8" });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async function parseSFC(code) {
|
|
138
|
+
try {
|
|
139
|
+
return parse(code, {
|
|
140
|
+
pad: "space"
|
|
141
|
+
}).descriptor || parse({
|
|
142
|
+
source: code
|
|
143
|
+
});
|
|
144
|
+
} catch {
|
|
145
|
+
throw new Error(
|
|
146
|
+
`[vite-plugin-uni-pages] Vue3's "@vue/compiler-sfc" is required.`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function parseCustomBlock(block, filePath, options) {
|
|
151
|
+
const lang = block.lang ?? options.routeBlockLang;
|
|
152
|
+
debug.routeBlock(`use ${lang} parser`);
|
|
153
|
+
if (lang === "json5") {
|
|
154
|
+
try {
|
|
155
|
+
return JSON5.parse(block.content);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
throw new Error(
|
|
158
|
+
`Invalid JSON5 format of <${block.type}> content in ${filePath}
|
|
159
|
+
${err.message}`
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
} else if (lang === "json") {
|
|
163
|
+
try {
|
|
164
|
+
return JSON.parse(block.content);
|
|
165
|
+
} catch (err) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
`Invalid JSON format of <${block.type}> content in ${filePath}
|
|
168
|
+
${err.message}`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
} else if (lang === "yaml" || lang === "yml") {
|
|
172
|
+
try {
|
|
173
|
+
return parse$1(block.content);
|
|
174
|
+
} catch (err) {
|
|
175
|
+
throw new Error(
|
|
176
|
+
`Invalid YAML format of <${block.type}> content in ${filePath}
|
|
177
|
+
${err.message}`
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async function getRouteBlock(path, options) {
|
|
183
|
+
const content = fs.readFileSync(path, "utf8");
|
|
184
|
+
const parsedSFC = await parseSFC(content);
|
|
185
|
+
const blockStr = parsedSFC?.customBlocks.find((b) => b.type === "route");
|
|
186
|
+
if (!blockStr)
|
|
187
|
+
return;
|
|
188
|
+
const result = parseCustomBlock(blockStr, path, options);
|
|
189
|
+
return result;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
class PageContext {
|
|
193
|
+
constructor(userOptions, viteRoot = process.cwd()) {
|
|
194
|
+
this.pagesPath = [];
|
|
195
|
+
this.pageMetaData = [];
|
|
196
|
+
this.resolvedPagesJSONPath = "";
|
|
197
|
+
this.rawOptions = userOptions;
|
|
198
|
+
this.root = slash(viteRoot);
|
|
199
|
+
debug.options("root", this.root);
|
|
200
|
+
this.options = resolveOptions(userOptions, this.root);
|
|
201
|
+
this.resolvedPagesJSONPath = path.join(this.root, this.options.outDir, OUTPUT_NAME);
|
|
202
|
+
debug.options(this.options);
|
|
203
|
+
}
|
|
204
|
+
setLogger(logger) {
|
|
205
|
+
this.logger = logger;
|
|
206
|
+
}
|
|
207
|
+
async loadUserPagesConfig() {
|
|
208
|
+
const { config } = await loadConfig({ sources: [{ files: "pages.config" }] });
|
|
209
|
+
if (!config) {
|
|
210
|
+
this.logger?.warn("Can't found pages.config, please create pages.config.(ts|mts|cts|js|cjs|mjs|json)");
|
|
211
|
+
process.exit(-1);
|
|
212
|
+
}
|
|
213
|
+
this.pagesGlobConfig = config;
|
|
214
|
+
debug.options(config);
|
|
215
|
+
}
|
|
216
|
+
async scanPages() {
|
|
217
|
+
const pageDirFiles = this.options.dirs.map((dir) => {
|
|
218
|
+
const pagesDirPath = slash(path.resolve(this.options.root, dir));
|
|
219
|
+
const basePath = slash(path.join(this.options.root, this.options.outDir));
|
|
220
|
+
const files = getPageFiles(pagesDirPath, this.options);
|
|
221
|
+
debug.pages(dir, files);
|
|
222
|
+
const pagePaths = files.map((file) => slash(file)).map((file) => ({
|
|
223
|
+
relativePath: path.relative(basePath, slash(path.resolve(pagesDirPath, file))),
|
|
224
|
+
absolutePath: slash(path.resolve(pagesDirPath, file))
|
|
225
|
+
}));
|
|
226
|
+
return { dir, files: pagePaths };
|
|
227
|
+
});
|
|
228
|
+
this.pagesPath = pageDirFiles.map((page) => page.files).flat();
|
|
229
|
+
debug.pages(this.pagesPath);
|
|
230
|
+
}
|
|
231
|
+
setupViteServer(server) {
|
|
232
|
+
if (this._server === server)
|
|
233
|
+
return;
|
|
234
|
+
this._server = server;
|
|
235
|
+
this.setupWatcher(server.watcher);
|
|
236
|
+
}
|
|
237
|
+
setupWatcher(watcher) {
|
|
238
|
+
watcher.on("add", async (path2) => {
|
|
239
|
+
path2 = slash(path2);
|
|
240
|
+
if (!isTargetFile(path2))
|
|
241
|
+
return;
|
|
242
|
+
debug.pages(`File added: ${path2}`);
|
|
243
|
+
this.updatePagesJSON();
|
|
244
|
+
this.onUpdate();
|
|
245
|
+
});
|
|
246
|
+
watcher.on("change", async (path2) => {
|
|
247
|
+
path2 = slash(path2);
|
|
248
|
+
if (!isTargetFile(path2) && !isConfigFile(path2))
|
|
249
|
+
return;
|
|
250
|
+
debug.pages(`File changed: ${path2}`);
|
|
251
|
+
this.updatePagesJSON();
|
|
252
|
+
this.onUpdate();
|
|
253
|
+
});
|
|
254
|
+
watcher.on("unlink", async (path2) => {
|
|
255
|
+
path2 = slash(path2);
|
|
256
|
+
if (!isTargetFile(path2))
|
|
257
|
+
return;
|
|
258
|
+
debug.pages(`File removed: ${path2}`);
|
|
259
|
+
this.updatePagesJSON();
|
|
260
|
+
this.onUpdate();
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
onUpdate() {
|
|
264
|
+
if (!this._server)
|
|
265
|
+
return;
|
|
266
|
+
invalidatePagesModule(this._server);
|
|
267
|
+
debug.hmr("Reload generated pages.");
|
|
268
|
+
this._server.ws.send({
|
|
269
|
+
type: "full-reload"
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
async parsePage(page) {
|
|
273
|
+
const { relativePath, absolutePath } = page;
|
|
274
|
+
const routeBlock = await getRouteBlock(absolutePath, this.options);
|
|
275
|
+
const relativePathWithFileName = relativePath.replace(path.extname(relativePath), "");
|
|
276
|
+
const pageMetaDatum = { path: relativePathWithFileName, type: "page" };
|
|
277
|
+
if (routeBlock)
|
|
278
|
+
Object.assign(pageMetaDatum, routeBlock);
|
|
279
|
+
return pageMetaDatum;
|
|
280
|
+
}
|
|
281
|
+
async mergePageMetaData() {
|
|
282
|
+
const generatedPageMetaData = await Promise.all(
|
|
283
|
+
this.pagesPath.map(async (page) => await this.parsePage(page))
|
|
284
|
+
);
|
|
285
|
+
const customPageMetaData = this.pagesGlobConfig?.pages || [];
|
|
286
|
+
if (!this.options.mergePages) {
|
|
287
|
+
this.pageMetaData = customPageMetaData;
|
|
288
|
+
} else {
|
|
289
|
+
if (this.pagesGlobConfig?.pages)
|
|
290
|
+
this.pageMetaData = mergePageMetaDataArray(generatedPageMetaData.concat(customPageMetaData));
|
|
291
|
+
else
|
|
292
|
+
this.pageMetaData = generatedPageMetaData;
|
|
293
|
+
}
|
|
294
|
+
debug.pages(generatedPageMetaData);
|
|
295
|
+
}
|
|
296
|
+
async updatePagesJSON() {
|
|
297
|
+
checkPagesJsonFile(this.resolvedPagesJSONPath);
|
|
298
|
+
this.options.onBeforeLoadUserConfig(this);
|
|
299
|
+
await this.loadUserPagesConfig();
|
|
300
|
+
this.options.onAfterLoadUserConfig(this);
|
|
301
|
+
if (this.options.mergePages) {
|
|
302
|
+
this.options.onBeforeScanPages(this);
|
|
303
|
+
await this.scanPages();
|
|
304
|
+
this.options.onAfterScanPages(this);
|
|
305
|
+
}
|
|
306
|
+
this.options.onBeforeMergePageMetaData(this);
|
|
307
|
+
await this.mergePageMetaData();
|
|
308
|
+
this.options.onAfterMergePageMetaData(this);
|
|
309
|
+
this.options.onBeforeWriteFile(this);
|
|
310
|
+
const pagesJson = JSON.stringify({ ...this.pagesGlobConfig, pages: this.pageMetaData }, null, 2);
|
|
311
|
+
writeFileSync(this.resolvedPagesJSONPath, pagesJson);
|
|
312
|
+
this.options.onAfterWriteFile(this);
|
|
313
|
+
}
|
|
314
|
+
async virtualModule() {
|
|
315
|
+
return `export const pages = ${this.resolveRoutes()};`;
|
|
316
|
+
}
|
|
317
|
+
resolveRoutes() {
|
|
318
|
+
return JSON.stringify(this.pageMetaData, null, 2);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function defineUniPages(config) {
|
|
323
|
+
return config;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const VitePluginUniPages = (userOptions = {}) => {
|
|
327
|
+
let ctx;
|
|
328
|
+
const resolvedPagesJSONPath = path.join(process.cwd(), userOptions.outDir ?? "src", OUTPUT_NAME);
|
|
329
|
+
checkPagesJsonFile(resolvedPagesJSONPath);
|
|
330
|
+
return {
|
|
331
|
+
name: "vite-plugin-uni-pages",
|
|
332
|
+
enforce: "pre",
|
|
333
|
+
async configResolved(config) {
|
|
334
|
+
ctx = new PageContext(userOptions, config.root);
|
|
335
|
+
ctx.setLogger(config.logger);
|
|
336
|
+
ctx.updatePagesJSON();
|
|
337
|
+
if (config.build.watch && config.command === "build")
|
|
338
|
+
ctx.setupWatcher(chokidar.watch(ctx.options.dirs));
|
|
339
|
+
},
|
|
340
|
+
async transform(code, id) {
|
|
341
|
+
if (!/\.vue$/.test(id))
|
|
342
|
+
return null;
|
|
343
|
+
const s = new MagicString(code.toString());
|
|
344
|
+
const routeBlockMatches = s.original.matchAll(/<route[^>]*>([\s\S]*?)<\/route>/g);
|
|
345
|
+
for (const match of routeBlockMatches) {
|
|
346
|
+
const index = match.index;
|
|
347
|
+
const length = match[0].length;
|
|
348
|
+
s.remove(index, index + length);
|
|
349
|
+
}
|
|
350
|
+
return s.toString();
|
|
351
|
+
},
|
|
352
|
+
configureServer(server) {
|
|
353
|
+
ctx.setupViteServer(server);
|
|
354
|
+
},
|
|
355
|
+
resolveId(id) {
|
|
356
|
+
if (id === MODULE_ID_VIRTUAL)
|
|
357
|
+
return RESOLVED_MODULE_ID_VIRTUAL;
|
|
358
|
+
},
|
|
359
|
+
load(id) {
|
|
360
|
+
if (id === RESOLVED_MODULE_ID_VIRTUAL)
|
|
361
|
+
return ctx.virtualModule();
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
export { FILE_EXTENSIONS, MODULE_ID_VIRTUAL, OUTPUT_NAME, PageContext, RESOLVED_MODULE_ID_VIRTUAL, VitePluginUniPages, checkPagesJsonFile, debug, VitePluginUniPages as default, defineUniPages, extsToGlob, getPageFiles, getRouteBlock, invalidatePagesModule, isConfigFile, isTargetFile, mergePageMetaDataArray, parseCustomBlock, parseSFC, resolveOptions, resolvePageDirs, writeFileSync };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uni-helper/vite-plugin-uni-pages",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0
|
|
4
|
+
"version": "0.1.0",
|
|
5
5
|
"packageManager": "pnpm@7.16.1",
|
|
6
6
|
"description": "File system based routing for uni-app applications using Vite",
|
|
7
7
|
"author": "KeJun",
|
|
@@ -27,44 +27,30 @@
|
|
|
27
27
|
"main": "./dist/index.mjs",
|
|
28
28
|
"module": "./dist/index.js",
|
|
29
29
|
"types": "./dist/index.d.ts",
|
|
30
|
-
"typesVersions": {
|
|
31
|
-
"*": {
|
|
32
|
-
"*": [
|
|
33
|
-
"./dist/*",
|
|
34
|
-
"./dist/index.d.ts"
|
|
35
|
-
],
|
|
36
|
-
"client": [
|
|
37
|
-
"./client.d.ts"
|
|
38
|
-
]
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
30
|
"files": [
|
|
42
31
|
"dist",
|
|
43
32
|
"client.d.ts"
|
|
44
33
|
],
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@vue/compiler-sfc": "^3.2.45",
|
|
36
|
+
"chokidar": "^3.5.3",
|
|
37
|
+
"debug": "^4.3.4",
|
|
38
|
+
"fast-glob": "^3.2.12",
|
|
39
|
+
"json5": "^2.2.3",
|
|
40
|
+
"lodash-es": "^4.17.21",
|
|
41
|
+
"magic-string": "^0.27.0",
|
|
42
|
+
"unconfig": "^0.3.7",
|
|
43
|
+
"yaml": "^2.2.1"
|
|
52
44
|
},
|
|
53
45
|
"devDependencies": {
|
|
54
|
-
"@
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"vite": "^
|
|
46
|
+
"@antfu/utils": "^0.7.2",
|
|
47
|
+
"@types/debug": "^4.1.7",
|
|
48
|
+
"@types/lodash-es": "^4.17.6",
|
|
49
|
+
"@types/node": "^18.11.18",
|
|
50
|
+
"vite": "^4.0.3"
|
|
59
51
|
},
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"consola": "^2.15.3",
|
|
64
|
-
"defu": "^6.1.1",
|
|
65
|
-
"fast-glob": "^3.2.12",
|
|
66
|
-
"jsonc-parser": "^3.2.0",
|
|
67
|
-
"type-fest": "^3.2.0",
|
|
68
|
-
"unconfig": "^0.3.7"
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "unbuild",
|
|
54
|
+
"stub": "unbuild --stub"
|
|
69
55
|
}
|
|
70
|
-
}
|
|
56
|
+
}
|
package/README.Zh-CN.md
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# @uni-helper/vite-plugin-uni-pages
|
|
2
|
-
|
|
3
|
-
在 Vite 驱动的 uni-app 上使用基于文件的路由系统
|
|
4
|
-
|
|
5
|
-
[English](./README.md) | 简体中文
|
|
6
|
-
|
|
7
|
-
## 安装
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
pnpm i -D @uni-helper/vite-plugin-uni-pages
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## 使用
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
// vite.config.ts
|
|
17
|
-
import { defineConfig } from "vite";
|
|
18
|
-
import Uni from "@dcloudio/vite-plugin-uni";
|
|
19
|
-
import UniPages from "@uni-helper/vite-plugin-uni-pages";
|
|
20
|
-
// It is recommended to put it in front of Uni
|
|
21
|
-
export default defineConfig({
|
|
22
|
-
plugins: [UniPages(), Uni()],
|
|
23
|
-
});
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
在 `pages.config.(ts|mts|cts|js|cjs|mjs|json)` 定义全局属性
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
// pages.config.ts
|
|
30
|
-
import { definePages } from "@uni-helper/vite-plugin-uni-pages";
|
|
31
|
-
|
|
32
|
-
export default definePages({
|
|
33
|
-
// You can also specify pages, and the content will be merged
|
|
34
|
-
pages: []
|
|
35
|
-
globalStyle: {
|
|
36
|
-
navigationBarTextStyle: "black",
|
|
37
|
-
navigationBarTitleText: "@uni-helper",
|
|
38
|
-
navigationBarBackgroundColor: "#F8F8F8",
|
|
39
|
-
backgroundColor: "#F8F8F8",
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
现在所有的 page 都会被自动发现!
|
|
45
|
-
|
|
46
|
-
你可以在页面中使用 route-block 来指定元数据
|
|
47
|
-
|
|
48
|
-
```vue
|
|
49
|
-
<!-- index.vue -->
|
|
50
|
-
<!-- use type to set index -->
|
|
51
|
-
<route lang="json" type="home">
|
|
52
|
-
{
|
|
53
|
-
"style": { "navigationBarTitleText": "@uni-helper" }
|
|
54
|
-
}
|
|
55
|
-
</route>
|
|
56
|
-
|
|
57
|
-
<!-- other.vue -->
|
|
58
|
-
<route lang="json">
|
|
59
|
-
{
|
|
60
|
-
"style": { "navigationBarTitleText": "@uni-helper" },
|
|
61
|
-
"any-meta-data": "hello"
|
|
62
|
-
}
|
|
63
|
-
</route>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
导入虚拟模块即可访问所有页面的元数据
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
/// <reference types="@uni-helper/vite-plugin-uni-pages/client" />
|
|
70
|
-
import { pages } from "virtual:uni-pages";
|
|
71
|
-
console.log(pages);
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## 配置
|
|
75
|
-
|
|
76
|
-
查看 [types.ts](./src/types.ts)
|
|
77
|
-
|
|
78
|
-
## 钩子
|
|
79
|
-
|
|
80
|
-
你不能在 `pages.json` 中使用类似 `#ifdef H5`, 但是使用 [hooks](./src/types.ts) 可以改变 pagesMeta.
|
|
81
|
-
|
|
82
|
-
```ts
|
|
83
|
-
// vite.config.ts
|
|
84
|
-
UniPages({
|
|
85
|
-
onBeforeWriteFile(ctx) {
|
|
86
|
-
ctx.pagesMeta = ctx.pagesMeta?.filter((v) => !v.path.includes("test"));
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
...
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
这是条件编译的一个很好的替代方案, 你还可以在 `vite.config.ts` 中使用 `exclude` 来排除部分页面。
|
|
93
|
-
|
|
94
|
-
怎么做? 打印 `process.env` 然后找到 `UNI_*`, 我相信你已经会了
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/constant.ts","../src/context/index.ts","../src/config/index.ts"],"sourcesContent":["import { ModuleNode, normalizePath, Plugin } from \"vite\";\nimport { ResolvedOptions, UserOptions } from \"./types\";\nimport { isPagePath, logger } from \"./utils\";\nimport { virtualModuleId, resolvedVirtualModuleId } from \"./constant\";\nimport { Context } from \"./context\";\n\nexport * from \"./config\";\n\nfunction resolveOptions(userOptions: UserOptions): ResolvedOptions {\n return {\n pagesDir: \"src/pages\",\n outDir: \"src\",\n exclude: [],\n onBeforeLoadUserConfig: () => {},\n onAfterLoadUserConfig: () => {},\n onBeforeScanPages: () => {},\n onAfterScanPages: () => {},\n onBeforeMergePagesMeta: () => {},\n onAfterMergePagesMeta: () => {},\n onBeforeWriteFile: () => {},\n onAfterWriteFile: () => {},\n ...userOptions,\n };\n}\n\nexport const VitePluginUniPages = async (\n userOptions: UserOptions = {}\n): Promise<Plugin> => {\n const options = resolveOptions(userOptions);\n logger.debug(\"Create uni-pages context with\", options);\n const ctx = new Context(options);\n return {\n name: \"vite-plugin-uni-pages\",\n enforce: \"pre\",\n async configureServer({ watcher, moduleGraph, ws }) {\n const pagesConfigSourcePaths = await ctx.pagesConfigSourcePaths();\n logger.debug(\"Add watcher\", pagesConfigSourcePaths);\n watcher.add(pagesConfigSourcePaths);\n\n const reloadModule = (module: ModuleNode | undefined, path = \"*\") => {\n if (module) {\n moduleGraph.invalidateModule(module);\n if (ws) {\n ws.send({\n path,\n type: \"full-reload\",\n });\n }\n }\n };\n const updateVirtualModule = () => {\n logger.debug(\"Update virtualModule\");\n const module = moduleGraph.getModuleById(resolvedVirtualModuleId);\n reloadModule(module);\n };\n\n watcher.on(\"change\", async (path) => {\n if (\n pagesConfigSourcePaths.includes(normalizePath(path)) ||\n isPagePath(path, options)\n ) {\n await ctx.createOrUpdatePagesJSON();\n updateVirtualModule();\n }\n });\n watcher.on(\"add\", async (path) => {\n if (isPagePath(path, options)) {\n await ctx.createOrUpdatePagesJSON();\n updateVirtualModule();\n }\n });\n watcher.on(\"unlink\", async (path) => {\n if (isPagePath(path, options)) {\n await ctx.createOrUpdatePagesJSON();\n updateVirtualModule();\n }\n });\n },\n resolveId(id) {\n if (id === virtualModuleId) {\n return resolvedVirtualModuleId;\n }\n },\n\n load(id) {\n if (id === resolvedVirtualModuleId) {\n return ctx.virtualModule();\n }\n },\n };\n};\n\nexport default VitePluginUniPages;\n","import { resolve } from \"path\";\nimport { ResolvedOptions } from \"./types\";\nimport { createFilter } from \"vite\";\nimport consola from \"consola\";\n\nexport const isPagePath = (path: string, options: ResolvedOptions) => {\n const dirPath = resolve(process.cwd(), options.pagesDir);\n const filter = createFilter(\n dirPath + \"/**/*.(vue|nvue|uvue)\",\n options.exclude\n );\n return filter(path);\n};\n\nexport const logger = consola.create({\n defaults: {\n tag: \"vite-plugin-uni-pages\",\n },\n});\n","export const virtualModuleId = \"virtual:uni-pages\";\nexport const resolvedVirtualModuleId = \"\\0\" + virtualModuleId;\n","import { extname, join, relative, resolve } from \"path\";\nimport { loadConfig } from \"unconfig\";\nimport { normalizePath } from \"vite\";\nimport { PagesConfig } from \"../config/types\";\nimport { PageMeta, PagePathInfo, ResolvedOptions } from \"../types\";\nimport fg from \"fast-glob\";\nimport { parse as JSONParse } from \"jsonc-parser\";\nimport { parse } from \"@vue/compiler-dom\";\nimport fs from \"fs\";\nimport { defu } from \"defu\";\nimport { logger } from \"../utils\";\nexport class Context {\n options: ResolvedOptions;\n pagesConfig!: PagesConfig;\n pagesPathInfo: PagePathInfo[] = [];\n pagesMeta: PageMeta[] = [];\n constructor(options: ResolvedOptions) {\n this.options = options;\n this.createOrUpdatePagesJSON();\n }\n\n async loadUserPagesConfig() {\n const { config } = await loadConfig({\n sources: [\n {\n files: \"pages.config\",\n },\n ],\n merge: false,\n });\n if (!config) {\n logger.error(\n \"Can't found pages.config, please create pages.config.(ts|mts|cts|js|cjs|mjs|json)\"\n );\n process.exit(-1);\n }\n logger.debug(\"Loaded user pages config\", config);\n this.pagesConfig = config as PagesConfig;\n }\n\n async scanPages() {\n const files = await fg(\"**/*.(vue|nvue|uvue)\", {\n ignore: [\"node_modules\", \".git\", \"**/__*__/*\", ...this.options.exclude],\n onlyFiles: true,\n cwd: resolve(process.cwd(), this.options.pagesDir),\n });\n const basePath = relative(\n resolve(process.cwd(), this.options.outDir),\n this.options.pagesDir\n );\n this.pagesPathInfo = files.map((file) => {\n return {\n relative: normalizePath(join(basePath, file)),\n absolute: normalizePath(\n resolve(process.cwd(), this.options.pagesDir, file)\n ),\n };\n });\n logger.debug(\"Scanned pages dir\", this.pagesPathInfo);\n }\n\n async parsePage({ relative, absolute }: PagePathInfo): Promise<PageMeta> {\n const code = await fs.promises.readFile(absolute, {\n encoding: \"utf-8\",\n });\n const t = parse(code);\n const path = relative.replace(extname(relative), \"\");\n let pageMeta: PageMeta = {\n path,\n type: \"page\",\n };\n t?.children.forEach((v) => {\n if (v.type !== 1) {\n return;\n }\n if (v.tag === \"route\") {\n v.props.forEach((prop) => {\n if (prop.type === 6 && prop.name === \"type\") {\n pageMeta.type = prop.value?.content ?? pageMeta.type;\n }\n });\n const astContent = v.children?.[0];\n if (astContent && astContent.type === 2) {\n const _pageMeta = JSONParse(astContent.content);\n Object.keys(_pageMeta).forEach((key) => {\n pageMeta[key] = _pageMeta[key];\n });\n // overwrite path\n pageMeta[\"path\"] = path;\n }\n }\n });\n return pageMeta;\n }\n\n async mergePagesMeta() {\n const pagesMeta = await Promise.all(\n this.pagesPathInfo?.map(async (page) => await this.parsePage(page))\n );\n const pages = Object.values(defu({}, pagesMeta, this.pagesConfig.pages));\n // @ts-ignore\n pages.sort((a) => (a.type === \"home\" ? -1 : 0));\n // @ts-ignore\n this.pagesMeta = pages;\n logger.debug(\"merged pages\", this.pagesMeta);\n }\n\n async createOrUpdatePagesJSON() {\n const outputName = \"pages.json\";\n const resolvedOutput = normalizePath(\n resolve(process.cwd(), this.options.outDir, outputName)\n );\n\n // 如果不存在,先输出一个占位文件\n if (!fs.existsSync(resolvedOutput)) {\n fs.writeFileSync(resolvedOutput, `{\"pages\": [{\"path\": \"\"}]}`, {\n encoding: \"utf-8\",\n });\n }\n\n this.options.onBeforeLoadUserConfig(this);\n await this.loadUserPagesConfig();\n this.options.onAfterLoadUserConfig(this);\n\n this.options.onBeforeScanPages(this);\n await this.scanPages();\n this.options.onAfterScanPages(this);\n\n this.options.onBeforeMergePagesMeta(this);\n await this.mergePagesMeta();\n this.options.onAfterMergePagesMeta(this);\n\n this.options.onBeforeWriteFile(this);\n fs.writeFileSync(resolvedOutput, this.pagesJson, {\n encoding: \"utf-8\",\n });\n this.options.onAfterWriteFile(this);\n }\n\n async virtualModule() {\n return `export const pages = ${JSON.stringify(this.pagesMeta)};`;\n }\n\n async pagesConfigSourcePaths() {\n return await fg(\"pages.config.(ts|mts|cts|js|cjs|mjs|json)\", {\n deep: 0,\n onlyFiles: true,\n absolute: true,\n });\n }\n\n get pagesJson() {\n return JSON.stringify({\n ...this.pagesConfig,\n pages: this.pagesMeta,\n });\n }\n}\n","import { UserPagesConfig } from \"./types\";\nexport * from \"./types\";\nexport function definePages(config: UserPagesConfig) {\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,eAAkD;;;ACAlD,kBAAwB;AAExB,kBAA6B;AAC7B,qBAAoB;AAEb,IAAM,aAAa,CAAC,MAAc,YAA6B;AACpE,QAAM,cAAU,qBAAQ,QAAQ,IAAI,GAAG,QAAQ,QAAQ;AACvD,QAAM,aAAS;AAAA,IACb,UAAU;AAAA,IACV,QAAQ;AAAA,EACV;AACA,SAAO,OAAO,IAAI;AACpB;AAEO,IAAM,SAAS,eAAAC,QAAQ,OAAO;AAAA,EACnC,UAAU;AAAA,IACR,KAAK;AAAA,EACP;AACF,CAAC;;;AClBM,IAAM,kBAAkB;AACxB,IAAM,0BAA0B,OAAO;;;ACD9C,IAAAC,eAAiD;AACjD,sBAA2B;AAC3B,IAAAC,eAA8B;AAG9B,uBAAe;AACf,0BAAmC;AACnC,0BAAsB;AACtB,gBAAe;AACf,kBAAqB;AAEd,IAAM,UAAN,MAAc;AAAA,EAKnB,YAAY,SAA0B;AAFtC,yBAAgC,CAAC;AACjC,qBAAwB,CAAC;AAEvB,SAAK,UAAU;AACf,SAAK,wBAAw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AI,wBAAwB;AAClC,8BAAoB;AAAA,QACtB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,UAAU,IAAI;AACZ,UAAI,OAAO,iBAAiB;AAC1B,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IAEA,KAAK,IAAI;AACP,UAAI,OAAO,yBAAyB;AAClC,eAAO,IAAI,cAAc;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AACF;AAEA,IAAO,cAAQ;","names":["import_vite","consola","import_path","import_vite","fg","relative","fs","_a","JSONParse","module"]}
|