Skip to content

Configuration

Neodymium edited this page Jul 23, 2022 · 13 revisions

BundleBD includes many different options for configuration. Its behavior and options are configured in two different files: the Bundler Configuration and the Plugin Configuration. Each configuration type has defaults, so neither type of file is required, but they are highly reccomended.

Bundler Configuration

The Bundler Configuration configures the basic behavior of the bundler in a bundlebd.config.json file in the root directory.

entry

A relative path to the entry folder for a plugin. This is the folder that contains a plugin's main file and Plugin Configuration file. You can use [plugin] anywhere in the value to refer to a Plugin Name argument passed to the command.

Defaults to src.

output

A relative path to the folder that a bundled plugin will be placed into. You can use [plugin] anywhere in the value to refer to a Plugin Name argument passed to the command.

Defaults to dist.

filename

The name of a bundled plugin file. You can use [plugin] anywhere in the value to refer to a Plugin Name argument passed to the command.

Defaults to [plugin].plugin.js.

readme

Either a boolean or a relative path to the folder that a README.md file will be placed into. You can use [plugin] anywhere in the value to refer to a Plugin Name argument passed to the command. If given a value of true and not a path, the README.md file will be placed in the same folder as the bundled plugin.

If true or a valid output path, the bundler will look for a README.md file in the plugin's entry folder, parse it with the plugin's meta using {{ and }} as delimeters, and copy the result to the given path or output folder.

As an example, if the value of readme is true:

src/README.md (input):

# {{name}}

{{description}}

by {{author}}

## Some other stuff here

dist/README.md (output):

# MyAmazingPlugin

A plugin that does absolutely nothing

by Neodymium

## Some other stuff here

If the value of readme was a path such as [plugin]/readme, the output would be placed in MyAmazingPlugin/readme/README.md instead.

Defaults to false.

bdPath

An absolute path to BetterDiscord's main folder. This is used to copy the bundled plugin to the plugins folder when Development Mode is enabled. If you want to disable copying the bundled plugin, set this value to none.

By default, will warn the user that no bdPath is set.

Example

// bundlebd.config.json

{
    "entry": "[plugin]/src",
    "output": "[plugin]/dist",
    "filename": "[plugin].plugin.js",
    "readme": "[plugin]",
    "bdPath": "C:/Users/Neodymium/AppData/Roaming/BetterDiscord"
}

Plugin Configuration

The Plugin Configuration configures the plugin-specific information and options in a config.json file in your plugin's entry folder.

meta

The plugin's metadata that will be used to generate the plugin's meta. See here for more information on each possible property.

Defaults to:

{
    "name": "Plugin", // Or the command's Plugin Name argument if passed
    "author": "Unknown",
    "description": "Plugin bundled with BundleBD",
    "version": "1.0.0"
}

What's the difference between the meta's name property and the Plugin Name argument?

Usually, the meta's name is for resolving the name of the plugin inside of the plugin itself, and the Plugin Name argument is for resolving file names and paths in the Bundler Configuration.

changelog

A ZLibrary style changelog array. See the Docs for more information on the specific options.

Excluded by default.

Note: Changelogs are only currently suported on plugins using ZLibrary.

entry

The relative path from the plugin's entry folder to the main file of the plugin.

Defaults to index.

zlibrary

A boolean that determines whether or not to bundle the plugin with ZeresPluginLibrary support.

Defaults to false.

Example

// MyAmazingPlugin/src/config.json (Using the entry folder from the Bundle Configuration example)

{
    "meta": {
        "name": "MyAmazingPlugin",
        "author": "Neodymium",
        "description": "A plugin that does absolutely nothing",
        "version": "1.0.0"
    },
    "changelog": [
        { "title": "Added", "items": ["Added stuff"] },
        { "title": "Fixed", "type": "fixed", "items": ["Fixed a bug", "Fixed another bug"] }
    ],
    "entry": "main.js",
    "zlibrary": true
}

Typescript Configuration

While by no means required, configuring Typescript can solve issues with Typescript not resolving typings, and can make development easier, even when not using Typescript. Thus, it is recommended. To configure Typescript, just add a tsconfig.json file in your root folder. Here's an example of a simple TSConfig with some recommended settings for using the bundler:

// tsconfig.json

{
    "compilerOptions": {
        "types": ["node", "bundlebd"],
        "resolveJsonModule": true,
        "allowSyntheticDefaultImports": true,
        "jsx": "react-jsx"
    }
}

For more information on TSConfig files, their options, and what each one does, see the TSConfig Reference.