Base class for creating swup plugins
npm install @swup/pluginBase class for creating swup plugins.
To create a new plugin, use the official swup plugin template.
It comes with detailed instructions and the required tooling.
Import the base class and extend your plugin from it.
``js
import Plugin from '@swup/plugin';
export default class PluginName extends Plugin {
name = 'PluginName';
mount() {}
unmount() {}
}
`
The official swup command-line interface has commands to help with
bundling and linting plugins.
`sh`
npm install --save-dev @swup/cli
Bundle the plugin for production using microbundle,
creating ESM and UMD builds.
`bashBundle and transpile plugin code for distribution
swup package:bundle
$3
Lint the plugin code using prettier and swup's recommended rules.
`bash
Lint plugin code
swup package:lintFix and format any lint errors
swup package:format
`$3
Check that the plugin's package.json file contains the required information for microbundle:
input, output, export map, amd name, etc.
`bash
Check plugin package info
swup package:check
``