async buildRoutes() {
        const {routes: routesConfig = [], rewrite: rewriteRules = [], pathRule} = this.config.router;
        this.flatRoutes = new Set();

        // generate routes according to pages dir
        this.routes = await generateRoutes(
            join(this.lavasDir, '../pages'),
            {
                routerOption: {pathRule}
            }
        );

        // merge with routes' config
        this.mergeWithConfig(this.routes, routesConfig, rewriteRules);

        // write route.js
        await this.writeRoutesSourceFile();

        if (!this.isDev) {
            // write routes.json
            await this.writeRoutesJsonFile();
        }
    }
output routes.js into .lavas according to /pages