Config & plugins

Plugins

Full reference for the Manic Plugin API and development lifecycle.

Plugins Reference

Plugins are the primary way to extend Manic's functionality. They allow you to hook into the development server, customize the build pipeline, and inject assets into the built application.

createPlugin

The createPlugin helper simplifies plugin development by providing a unified interface for both development and production environments.

import {  } from 'manicjs/config';

// Conceptual helper
const  = (: any[]) => '<xml></xml>';

export const  = (: { ?: boolean }) => {
  return ({
    : 'manic-plugin-sitemap',
    
    // Automatic dev/prod parity for static files
    : [
      {
        : '/sitemap.xml',
        : () => (.),
        : 'application/xml',
      },
    ],

    () {
      // Dev-only hooks
      .('<meta name="sitemap-plugin" content="enabled">');
    },

    () {
      // Build-only hooks
      .('<style>.sitemap-link { color: red; }</style>');
    }
  });
};

Technical Specification

ManicPlugin Interface

Prop

Type


Context APIs

Both configureServer and build hooks receive a context object that provides access to the project's state.

ManicPluginContext (Shared)

Prop

Type

ManicServerPluginContext (Server Only)

Prop

Type

ManicBuildPluginContext (Build Only)

Prop

Type


Best Practices

Production Parity: If you register a route in configureServer using addRoute, make sure to also emit the same content in a build hook (or use the staticFiles shorthand) so your application behaves identically in production and development.

Use the staticFiles shorthand in createPlugin whenever possible. It handles the dev/prod parity logic for you automatically.

On this page