Platinum sponsors

Server configuration

Tell the save server where your animations live.

Without a configuration, the save server searches every .js, .ts, .jsx, .tsx and .html file of your project outside node_modules and .git. On a larger project, narrow the search so each save is faster and lands in the right file.

editor.config.json

The setup command creates an editor.config.json file at your project root. Set scan.roots to the files that hold your animations:

{
  "$schema": "./node_modules/tweaks/config.schema.json",
  "scan": {
    "roots": ["src"],
    "exclude": ["dist", "build"]
  }
}
Name Accepts
scan.roots (opt) An Array of folders, files and glob patterns, relative to the project root. Defaults to the whole project
scan.exclude (opt) An Array of folder names to skip, such as build outputs. node_modules and .git are always skipped
scan.ext (opt) An Array of file extensions to search, without the dot. Defaults to ["js", "ts", "jsx", "tsx", "html"]
port (opt) A Number. The port npm run editor starts on, 7348 by default. A port you give to the command wins. The editor finds the save server on its own
allowedOrigins (opt) An Array of the page origins that may save, such as ["http://mysite.test"]. By default, a page on localhost or 127.0.0.1 may save, on any port. Not used with Vite
allowedAddresses (opt) An Array of the addresses of other machines that may save, such as ["172.17.0.1"] for a browser on the host of a devcontainer. Used only with Vite, when Vite listens on the network

Roots examples

Roots Searches
["src"] Every file in src, recursively
["src/anim.js"] One file
["src", "lib"] Several folders
["src", "demos/hero.js"] Folders and files together
["examples/*/index.js"] One file per subfolder
["src/**/*.anim.js"] Matching files anywhere in the tree

A save for a call in a file outside the roots fails. Exclude build outputs and copied examples, which repeat the ids of your calls.

Restart npm run editor, or your Vite dev server, after you edit the configuration.

Commands

Command Action
npx @animatorkit/editor Sets up the editor and creates editor.config.json
npm run editor Starts the save server on port 7348, or the next free port
npm run editor 7349 Starts the save server on the port you give
Previous
Next