Skip to main content
Framework

Configuration

Every root command loads the project's root.config.ts. This page covers the most common options. For the full list, see RootUserConfig in the API reference.

base

A path prefix for every URL on the site.

ts
// @/root.config.ts

import {defineConfig} from '@blinkk/root';

export default defineConfig({
  // The site serves at example.com/about/...
  base: '/about/',
});

domain

The site's canonical domain, used for the sitemap, canonical URLs, and other SEO tags.

ts
// @/root.config.ts

import {defineConfig} from '@blinkk/root';

export default defineConfig({
  domain: 'https://example.com',
});

elements

Configures where Root.js looks for custom elements. By default it scans elements/, and you can include additional directories (such as a shared design system) or exclude specific files.

ts
// @/root.config.ts

import path from 'node:path';
import {URL} from 'node:url';
import {defineConfig} from '@blinkk/root';

const rootDir = new URL('.', import.meta.url).pathname;
const designSystem = path.resolve(rootDir, '../../packages/designsystem');

export default defineConfig({
  elements: {
    include: [path.resolve(designSystem, './elements')],
  },
});

i18n

The site's locales and the URL format for localized pages. See Localization.

ts
// @/root.config.ts

import {defineConfig} from '@blinkk/root';

export default defineConfig({
  i18n: {
    locales: ['de', 'en', 'es', 'fr'],
    urlFormat: '/intl/[locale]/[base]/[path]',
  },
});

server.redirects

HTTP redirects handled by the Root.js server.

ts
// @/root.config.ts

import {defineConfig} from '@blinkk/root';

export default defineConfig({
  server: {
    redirects: [
      // Redirect /foo to /bar.
      {source: '/foo', destination: '/bar', type: 301},
    ],
  },
});

server.trailingSlash

By default, a page is served both with and without a trailing slash. Set trailingSlash to true to redirect URLs to add a trailing slash, or false to redirect URLs to remove it.

ts
// @/root.config.ts

import {defineConfig} from '@blinkk/root';

export default defineConfig({
  server: {
    // Enforce a trailing slash.
    trailingSlash: true,
  },
});

sitemap

Set sitemap: true to generate a sitemap.xml with hreflang links between localized pages. Make sure to set domain as well so the sitemap contains absolute URLs.

vite

Settings passed to Vite. See Configuring Vite.

ts
// @/root.config.ts

import path from 'node:path';
import {URL} from 'node:url';
import {defineConfig} from '@blinkk/root';

const rootDir = new URL('.', import.meta.url).pathname;

export default defineConfig({
  vite: {
    resolve: {
      alias: {
        '@': rootDir,
      },
    },
    css: {
      preprocessorOptions: {
        scss: {
          loadPaths: [path.resolve(rootDir, './styles')],
        },
      },
    },
  },
});
1
2
3
4
5
6
7
8
9
10
11
12
Breakpoint: