Gracile/Vite configuration

API references extracted from the Gracile code base.
Examples, functions, classes, constants, type declarations…

Function: gracile()

function gracile(config?): any[];

The main Vite plugin for loading the Gracile framework.

Parameters

Parameter Type Description

config?

GracileConfig

Gracile configuration.

Returns

any[]

Vite plugins. any is used to prevent Vite typings version mismatches for the plugin API.

Example

/vite.config.js

import { gracile } from '@gracile/gracile/plugin';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [gracile({ output: 'server' })],
});

Defined in

packages/engine/dist/plugin.d.ts:21

Interface: GracileConfig

Example

/vite.config.js

import { gracile } from '@gracile/gracile/plugin';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [
    gracile({
      output: 'server',

      dev: {
        locals: (_context) => {
          return {
            requestId: crypto.randomUUID(),
            userEmail: 'admin@admin.home.arpa',
          };
        },
      },

      routes: {
        exclude: ['**/a-defective-route.ts'],
      },
    }),
  ],
});

Properties

PropertyTypeDefault valueDescriptionDefined in
dev?objectundefinedSettings for the development mode.packages/engine/dist/user-config.d.ts:43
dev.locals?(context: object) => unknownundefinedGet incoming request context and apply locals for the Gracile request handler. Useful for mocking the production server. For server mode only.packages/engine/dist/user-config.d.ts:50
experimental?objectundefinedFuture, unstable features flags.packages/engine/dist/user-config.d.ts:99
experimental.generateRoutesTypings?booleanundefinedExperimental Automatically typed route paths.packages/engine/dist/user-config.d.ts:104
output?"static" | "server"'static'The target output for the build phase. See the documentation.packages/engine/dist/user-config.d.ts:39
pages?objectundefinedSettings for pages in /src/routes.packages/engine/dist/user-config.d.ts:66
pages.premises?objectundefinedPremises are the document and the properties necessary for page template rendering. You can access them via: - .../_my-route/__index.props.json - .../_my-route/__index.doc.html They are accessible with the dev/server handler and are outputted as static files for the static output or for server pre-rendered pages. They can be use for implementing client-side routing.packages/engine/dist/user-config.d.ts:81
pages.premises.exclude?string[]undefinedExclude routes with a glob filter array.packages/engine/dist/user-config.d.ts:93
pages.premises.expose?booleanfalsepackages/engine/dist/user-config.d.ts:85
pages.premises.include?string[]undefinedInclude routes with a glob filter array.packages/engine/dist/user-config.d.ts:89
routes?objectundefinedSettings for routes in /src/routes.packages/engine/dist/user-config.d.ts:57
routes.exclude?string[]undefinedExclude routes with an array of patterns. Useful for debugging.packages/engine/dist/user-config.d.ts:61