Skip to content
On this page

Config

DefineConfig

Create prext.config.js or prext.config.ts to define config.

  1. Default
ts
export default {};
js
module.exports = {};
  1. Using defineConfig()
ts
import { defineConfig } from 'prext/config';

export default defineConfig({
  /* config */
});
js
const { defineConfig } = require('prext/config');

module.exports = defineConfig({
  /* config */
});

Types

base

  • Type: string
  • Default: .

Project root directory. (only relative path)

routes

  • Type: string
  • Default: /pages/

Directory where page files are located.

middlewares

  • Type: Array<Middleware>

Middlewares Array

ts
function example(req, res, next) {
  req.message = 'Hello World';
  next();
}

export default {
  middlewares: [example],
};

port

  • Type: number
  • Default: 5050

Port

handler

  • Type: HandlerType

Custom Server Handler

ts
Prext({
  handler: (req, res, routes) => {
    // ...
  },
});

esbuild

  • Type: esbuild.BuildOptions

Esbuild build option.

plugins

  • Type: Plugin[]

TIP

reference: plugin

watch

  • Type: chokidar.WatchOptions

error

  • Type: (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;

allowAutoMiddlewares

  • Type: boolean

TIP

reference: auto middleware

middlewareDirectory

  • Type: string