Gracile/Vite configuration

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

Interface: GracileConfig

Defined in: packages/engine/dist/user-config.d.ts:32

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

Property Type Default value Description Defined in

dev?

object

undefined

Settings for the development mode.

packages/engine/dist/user-config.d.ts:57

dev.locals?

(context) => unknown

undefined

Get 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:64

experimental?

object

undefined

Future, unstable features flags.

packages/engine/dist/user-config.d.ts:147

experimental.generateRoutesTypings?

boolean

undefined

Experimental

Automatically typed route paths.

packages/engine/dist/user-config.d.ts:152

litSsr?

object

undefined

packages/engine/dist/user-config.d.ts:110

litSsr.renderInfo?

Partial<RenderInfo>

undefined

Lets you extend Gracile’s SSR pipeline with custom Lit SSR ElementRenderer subclasses. This is the foundation for features like Islands, which register a renderer for the <is-land> custom element to server-render components from other UI frameworks.

In most cases, you do not set this option manually — add-on plugins (like gracileIslands()) register their renderers automatically via the plugin context communication channel. However, you can use it directly for advanced use cases:

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

export default defineConfig({
  plugins: [
    gracile({
      litSsr: {
        renderInfo: {
          elementRenderers: [
            // Your custom ElementRenderer subclass
          ],
        },
      },
    }),
  ],
});

packages/engine/dist/user-config.d.ts:142

output?

"static" | "server"

'static'

The target output for the build phase.

See the documentation.

packages/engine/dist/user-config.d.ts:40

pages?

object

undefined

Settings for pages in /src/routes.

packages/engine/dist/user-config.d.ts:80

pages.premises?

object

undefined

Premises 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:95

pages.premises.exclude?

string[]

undefined

Exclude routes with a glob filter array.

packages/engine/dist/user-config.d.ts:107

pages.premises.expose?

boolean

false

packages/engine/dist/user-config.d.ts:99

pages.premises.include?

string[]

undefined

Include routes with a glob filter array.

packages/engine/dist/user-config.d.ts:103

routes?

object

undefined

Settings for routes in /src/routes.

packages/engine/dist/user-config.d.ts:71

routes.exclude?

string[]

undefined

Exclude routes with an array of patterns. Useful for debugging.

packages/engine/dist/user-config.d.ts:75

trailingSlash?

"always" | "never" | "ignore"

'ignore'

Controls how trailing slashes are matched on incoming URLs.

  • 'ignore' — Match regardless of whether a trailing / is present. /about and /about/ both resolve to the same route. (default)
  • 'always' — Only match URLs that include a trailing slash (e.g. /about/). Requests without one are redirected: 301 for GET, 308 for other methods.
  • 'never' — Only match URLs that do not include a trailing slash (e.g. /about). Requests with one are redirected: 301 for GET, 308 for other methods.

packages/engine/dist/user-config.d.ts:53