UNPKG

create-uniapp-pages-json

Version:
29 lines (28 loc) 1 kB
"use strict"; /* * @Author: shen * @Date: 2020-12-23 13:57:27 * @LastEditors: shen * @LastEditTime: 2020-12-24 16:55:22 * @Description: get module router config */ Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); exports.default = (function (routesPath) { var routes = []; routesPath.forEach(function (fullPath) { delete require.cache[require.resolve(fullPath)]; var config = require(fullPath); routes.push.apply(routes, tslib_1.__spread(config)); }); var rootRouteIndex = routes.findIndex(function (route) { return route.isRoot; }); if (rootRouteIndex > -1) { var rootRoute = routes[rootRouteIndex]; routes.splice(rootRouteIndex, 1); routes.unshift(rootRoute); } return routes.map(function (_a) { var path = _a.path, _b = _a.style, style = _b === void 0 ? {} : _b; return ({ path: path.indexOf('/') === 0 ? path.substr(1) : path, style: style }); }); });