|
| 1 | +import { Callout } from 'nextra/components'; |
| 2 | + |
| 3 | +# CommandKit Configuration |
| 4 | + |
| 5 | +CommandKit CLI can be configured using `commandkit.config` file in the root of your project directory (for example, by `package.json`). You can use either of the following files: |
| 6 | + |
| 7 | +- `commandkit.js` |
| 8 | +- `commandkit.config.js` |
| 9 | +- `commandkit.mjs` |
| 10 | +- `commandkit.config.mjs` |
| 11 | +- `commandkit.cjs` |
| 12 | +- `commandkit.config.cjs` |
| 13 | +- `commandkit.json` |
| 14 | +- `commandkit.config.json` |
| 15 | + |
| 16 | +Throughout this guide, we'll be using `commandkit.config.mjs` as an example. |
| 17 | + |
| 18 | +The following is the sample configuration required to run your bot: |
| 19 | + |
| 20 | +```js filename="commandkit.config.mjs" copy |
| 21 | +import { defineConfig } from 'commandkit'; |
| 22 | + |
| 23 | +export default defineConfig({ |
| 24 | + src: 'src', // The source directory of your project. |
| 25 | + main: 'index.mjs', // The JavaScript entry point of your project. |
| 26 | +}); |
| 27 | +``` |
| 28 | + |
| 29 | +## Options |
| 30 | + |
| 31 | +### `src` |
| 32 | + |
| 33 | +- Type: `string` |
| 34 | + |
| 35 | +The source directory of the project where your source code lives. |
| 36 | + |
| 37 | +### `main` |
| 38 | + |
| 39 | +- Type: `string` |
| 40 | + |
| 41 | +The entry point to your project. |
| 42 | + |
| 43 | +Example: If your source is structured as `src/index.ts`, this option must be set to `index.mjs`. This is because CommandKit always compiles your source code to esm format. |
| 44 | + |
| 45 | +<Callout type="warning"> |
| 46 | + The "src" part in this option isn't required because it's already defined in the `src` option. |
| 47 | +</Callout> |
| 48 | + |
| 49 | +### `watch` (optional) |
| 50 | + |
| 51 | +- Type: `boolean` |
| 52 | +- Default: `true` |
| 53 | + |
| 54 | +Whether to watch for file changes or not. |
| 55 | + |
| 56 | +### `outDir` (optional) |
| 57 | + |
| 58 | +- Type: `string` |
| 59 | +- Default: `"dist"` |
| 60 | + |
| 61 | +The output directory to emit the production build to. |
| 62 | + |
| 63 | +### `envExtra` (optional) |
| 64 | + |
| 65 | +- Type: `boolean` |
| 66 | +- Default: `true` |
| 67 | + |
| 68 | +Extra env utilities to load. This allows you to load environment variables in different formats, like `Date`, `JSON`, `Boolean`, etc. |
| 69 | + |
| 70 | +### `nodeOptions` (optional) |
| 71 | + |
| 72 | +- Type: `string[]` |
| 73 | +- Default: `[]` |
| 74 | + |
| 75 | +Options to pass to Node.js. |
| 76 | + |
| 77 | +### `clearRestartLogs` (optional) |
| 78 | + |
| 79 | +- Type: `boolean` |
| 80 | +- Default: `true` |
| 81 | + |
| 82 | +Whether or not to clear default restart logs. |
| 83 | + |
| 84 | +### `minify` (optional) |
| 85 | + |
| 86 | +- Type: `boolean` |
| 87 | +- Default: `false` |
| 88 | + |
| 89 | +Whether or not to minify the production build. |
| 90 | + |
| 91 | +### `sourcemap` (optional) |
| 92 | + |
| 93 | +- Type: `boolean` | `"inline"` |
| 94 | +- Default: `false` |
| 95 | + |
| 96 | +Whether or not to include sourcemaps in the production build. |
| 97 | + |
| 98 | +### `antiCrash` (optional) |
| 99 | + |
| 100 | +- Type: `boolean` |
| 101 | +- Default: `true` |
| 102 | + |
| 103 | +Whether or not to inject anti-crash script in the production build. |
| 104 | + |
| 105 | +### `requirePolyfill` (optional) |
| 106 | + |
| 107 | +- Type: `boolean` |
| 108 | +- Default: `true` |
| 109 | + |
| 110 | +Whether or not to polyfill `require` function. |
0 commit comments