Skip to content

Configuration

Makoo is configured through the makoo() Vite plugin. This file describes project-level behavior: how Makoo scans modules, which runtime defaults it should use, and how the final userscript is passed to vite-plugin-monkey.

ts
import { defineConfig } from 'vite';
import { makoo } from '@makoojs/cli';

export default defineConfig({
	plugins: [
		makoo({
			app: {
				name: 'my-script',
				version: '0.0.1',
				description: 'Enhance example.com with injected UI'
			},
			source: {
				include: ['*'],
				exclude: []
			},
			injector: {
				alive: false,
				scope: 'local',
				timeout: 5000
			},
			runtime: {
				setup: ['./injections/setup.ts']
			},
			monkey: {
				userscript: {
					match: ['https://example.com/*']
				}
			}
		})
	]
});

Use vite.config.ts for settings that affect the whole project. Use injections/manifest.ts for module-level behavior such as injectAt, component, match, alive, and hooks for a specific injection.

Option Groups

GroupPurpose
appMakoo app metadata and default userscript name/version
sourceWhich module folders are scanned under injections/
injectorRuntime defaults inherited by modules
runtimeSide-effect setup files imported before injector setup
monkeyvite-plugin-monkey userscript, server, and build options

app

app is required.

ts
makoo({
	app: {
		name: 'my-script',
		version: '0.0.1',
		description: 'Optional script description'
	}
});
FieldDescription
nameRequired app name. Also becomes the default userscript name
versionRequired version. Also becomes the default userscript version
descriptionOptional description. Also becomes the default userscript description

Values in monkey.userscript can still override the generated userscript metadata when you need more control.

source

source controls module scanning.

ts
makoo({
	source: {
		include: ['*'],
		exclude: ['draft-*']
	}
});

Makoo currently scans the fixed injections/ directory. The top-level manifest file is also fixed to manifest, so Makoo will look for files such as injections/manifest.ts and module-level files such as injections/panel/manifest.ts.

FieldDefaultDescription
include['*']Folder-name patterns to include under injections/
exclude[]Folder-name patterns to exclude under injections/

These patterns filter module folders, not page URLs. For page URL matching, use monkey.userscript.match for the whole userscript or module-level match in the manifest.

injector

injector defines runtime defaults for modules.

ts
makoo({
	injector: {
		alive: false,
		scope: 'local',
		timeout: 5000,
		hooks: {
			'run:start': (payload) => {
				console.log('[makoo] run started', payload);
			}
		}
	}
});
FieldDefaultDescription
alivefalseWhether modules should reinject when their mount disappears
scope'local'Reinjection observation scope, either 'local' or 'global'
timeout5000Time in milliseconds to wait for each target selector
hooks{}Global lifecycle hooks

Modules inherit these defaults unless they set their own alive, scope, timeout, or hooks in the manifest. A top-level manifest can also provide globalInjector, which is resolved as the runtime injector config for the scanned injection set.

runtime

runtime.setup imports side-effect files before Makoo creates and runs the injector.

ts
makoo({
	runtime: {
		setup: ['./injections/setup.ts', './injections/polyfills.ts']
	}
});

Use setup files for project-wide runtime preparation, such as installing globals, initializing shared services, or importing side-effect styles. Makoo tracks setup files and their local dependencies during development, so changing them triggers a structural update.

monkey

Most monkey options are passed to vite-plugin-monkey.

ts
makoo({
	monkey: {
		userscript: {
			namespace: 'npm/makoo',
			match: ['https://example.com/*'],
			grant: ['GM_getValue', 'GM_setValue']
		},
		server: {
			open: true,
			prefix: 'server:'
		},
		build: {
			fileName: 'my-script.user.js',
			metaFileName: true,
			autoGrant: true
		}
	}
});

Makoo manages a few vite-plugin-monkey details internally:

OptionMakoo behavior
entryGenerated by Makoo
clientAliasFixed internally
server.mountGmApiFixed internally

Do not set monkey.clientAlias or monkey.server.mountGmApi; Makoo validates and rejects those options because they would conflict with its runtime integration.

Defaults

The main defaults are:

OptionDefault
source.include['*']
source.exclude[]
injector.alivefalse
injector.scope'local'
injector.timeout5000
runtime.setup[]
monkey.align2
monkey.styleImporttrue
monkey.server.prefix'server:'
monkey.build.fileName${app.name}.user.js
monkey.build.metaFileNamefalse
monkey.build.autoGranttrue

Configuration Boundary

Keep this split in mind:

FileOwns
vite.config.tsProject metadata, scanning, global runtime defaults, userscript build/dev options
injections/manifest.tsInjection modules, target selectors, component paths, module URL rules
injections/<module>/Component code, module styles, module helpers, optional module manifest

This boundary keeps Makoo projects understandable as they grow.