Skip to main content
This guide covers building Sable from source for production deployment.

Production Build

To build Sable for production, run:
npm run build
This compiles the app into the dist/ directory using Vite’s production build system.

Build Output

The build process creates optimized production files in the dist/ directory:
  • Minified JavaScript bundles
  • Optimized CSS
  • Static assets (images, fonts, etc.)
  • Source maps (for debugging)

Build Configuration

The build is configured in vite.config.ts:
build: {
  outDir: 'dist',
  sourcemap: true,
  copyPublicDir: false,
  rollupOptions: {
    plugins: [inject({ Buffer: ['buffer', 'Buffer'] })],
  },
}

Deploying the Build

After building, you can copy the dist/ directory to your server and serve it with any static file server (nginx, Apache, etc.). For more information on deployment, see the Self-hosting guide.

Available Scripts

Sable includes several npm scripts for development and quality assurance:

Development

npm run dev      # Start development server
npm run preview  # Preview production build locally

Linting

npm run lint      # Run ESLint to check for code issues
npm run lint:fix  # Automatically fix ESLint issues

Formatting

npm run fmt        # Format code with Prettier
npm run fmt:check  # Check if code is formatted correctly

Type Checking

npm run typecheck  # Run TypeScript compiler to check types

Unused Code Detection

npm run knip  # Detect unused files, dependencies, and exports

Quality Checks Required for PRs

Before submitting a pull request, ensure all of these checks pass:
npm run fmt:check
npm run lint
npm run typecheck
npm run knip
Pull requests are not merged unless all quality checks are passing. Run these locally before opening or updating a pull request.

Build for Self-hosting

If you’re building Sable for self-hosting:
  1. Install dependencies:
    npm ci
    
  2. Build the application:
    npm run build
    
  3. The output in dist/ is ready to be served by your web server.
  4. Configure your homeservers and other options in config.json.
For deployment on a subdirectory, you need to update the base path in build.config.ts before building. For example, if you want to deploy on https://sable.moe/app, then set base: '/app'.

Build docs developers (and LLMs) love