47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
const {chalkTag, findPages, fsExtra, fs} = require("./tools");
|
|
const PageBase = require("./PageBase");
|
|
const start = () => {
|
|
chalkTag.info('开始生成pages.json...')
|
|
let json = {
|
|
easycom: {
|
|
autoscan: true,
|
|
custom: {
|
|
"^(Ai|V)(.*)": "@/components/$1$2.vue",
|
|
"^uni-(.*)": "@dcloudio/uni-ui/lib/uni-$1/uni-$1.vue"
|
|
}
|
|
},
|
|
pages: [
|
|
{path: 'pages/home', style: {navigationBarTitleText: "buy-lite"}},
|
|
],
|
|
subPackages: [
|
|
{root: "mods/", pages: []},
|
|
{root: "components/pages/", pages: []},
|
|
],
|
|
globalStyle: {
|
|
pageOrientation: "auto",
|
|
navigationBarTextStyle: "white",
|
|
navigationBarBackgroundColor: "#4181FF"
|
|
}
|
|
}
|
|
Promise.all([
|
|
findPages('src/components/pages', file => {
|
|
if (/.+\\pages\\[^\\]+\.vue/g.test(file)) {
|
|
const app = new PageBase(file.replace(/^src\\components\\pages\\(.*).vue/g, '$1').replace(/\\/g, '/'), fs.readFileSync(file).toString())
|
|
return json.subPackages[1].pages.push(app)
|
|
}
|
|
}),
|
|
findPages('src/mods', file => {
|
|
if (/.+\\App[^\\]+\\[^\\]+\.vue/g.test(file)) {
|
|
const app = new PageBase(file.replace(/^src\\mods\\(.*).vue/g, '$1').replace(/\\/g, '/'), fs.readFileSync(file).toString())
|
|
return json.subPackages[0].pages.push(app)
|
|
}
|
|
}),
|
|
]).then(() => {
|
|
fsExtra.outputJson('src/pages.json', json, () => {
|
|
chalkTag.done('生成pages.json')
|
|
})
|
|
})
|
|
}
|
|
|
|
start();
|