Skip to main content
MN Rails is the modern scaffold for MarginNote add-ons. It handles project creation, building, packaging, and deployment, and it ships a rich set of templates and scaffolds to get you productive quickly.

Creating a project

Create a project with the create command:
The command runs interactively:

Non-interactive creation

Every option can be passed on the command line:
An explicitly specified target directory must be empty. If you omit the directory and the current directory contains visible files, the command creates a subdirectory after you confirm its name.

Frameworks and add-on shapes

Two add-on shapes are available:
  • Panel only: a standard scene add-on whose page entry is index.html. MarginNote generates the add-on panel and menus from mnaddon.json.
  • Hybrid: a combination of a scene add-on and a classic add-on, with a web page and a two-way bridge module. See Beyond the panel.

Project structure

my-addon
index.html
mnaddon.json
eslint.config.mjs
vite.config.ts
package.json
src
App.tsx
main.tsx
bridge.ts
native/ exists only in hybrid projects. Panel-only projects do not create this directory, and their build output must not contain a root-level main.js. Key files and what they do:

Project commands

The project provides the following scripts:

Building and deploying

First build:
The build output goes to dist/. Both package and sync require an existing dist/ that passes the output checks. Local deployment:
sync performs these steps:
  1. Verifies that dist/ matches the current add-on shape.
  2. Locates the local MarginNote add-on directory.
  3. Replaces files through a temporary directory, restoring the previous add-on if anything fails.
  4. Restarts MarginNote.
Local deployment is supported on macOS only.

Producing installers

Installers are written to release/:
  • <addon-name>-<version>.mnaddon: the compressed add-on directory.
  • <template-name>-<version>.mntemplate: a scene template package containing the template configuration, localization files, and add-on files.
For how to write template configuration, see Minimal package and Adding add-ons.