This commit is contained in:
Yvan
2026-08-17 15:23:57 +08:00
parent 05b49cd86a
commit 083cc3a9ea
24 changed files with 639 additions and 287 deletions
+7 -2
View File
@@ -15,14 +15,19 @@ const pathMapPlugin = () => ({
const result = {}
const walk = (directory) => {
if (!fs.existsSync(directory)) return
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
const entries = fs.readdirSync(directory, { withFileTypes: true })
.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)
for (const entry of entries) {
const filename = path.join(directory, entry.name)
if (entry.isDirectory()) {
walk(filename)
} else if (filename.endsWith('.vue')) {
const source = fs.readFileSync(filename, 'utf8')
const match = source.match(/defineOptions\s*\(\s*{[\s\S]*?name:\s*['"]([^'"]+)['"]/)
if (match) result[`/src/${filename.replace(/^src\//, '')}`] = match[1]
if (match) {
const relativePath = path.relative('src', filename).split(path.sep).join('/')
result[`/src/${relativePath}`] = match[1]
}
}
}
}