|
| 1 | +import { Callout } from 'nextra/components'; |
| 2 | + |
| 3 | +# commandkit.config.js options |
| 4 | + |
| 5 | +<Callout type="warning"> |
| 6 | + This is currently only available in the [development |
| 7 | + version](/docs/installation#development-version) of CommandKit. |
| 8 | +</Callout> |
| 9 | + |
| 10 | +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: |
| 11 | + |
| 12 | +- `commandkit.js` |
| 13 | +- `commandkit.config.js` |
| 14 | +- `commandkit.mjs` |
| 15 | +- `commandkit.config.mjs` |
| 16 | +- `commandkit.cjs` |
| 17 | +- `commandkit.config.cjs` |
| 18 | +- `commandkit.json` |
| 19 | +- `commandkit.config.json` |
| 20 | + |
| 21 | +Throughout this guide, we'll be using `commandkit.config.mjs` as an example. |
| 22 | + |
| 23 | +The following is the sample configuration required to run your bot: |
| 24 | + |
| 25 | +```js title="commandkit.config.mjs" |
| 26 | +import { defineConfig } from 'commandkit'; |
| 27 | + |
| 28 | +export default defineConfig({ |
| 29 | + src: 'src', // The source directory of your project. |
| 30 | + main: 'index.mjs', // The JavaScript entry point of your project. |
| 31 | +}); |
| 32 | +``` |
| 33 | + |
| 34 | +## Options |
| 35 | + |
| 36 | +### `src`: string |
| 37 | + |
| 38 | +The source directory of the project. This is where your source code lives. This is a required option. |
| 39 | + |
| 40 | +### `main`: string |
| 41 | + |
| 42 | +The JavaScript entry point of your project. This is a required option. |
| 43 | + |
| 44 | +For example, if your source is structured as `src/index.ts`, you'd need to set this option to `index.mjs`. This is because CommandKit always compiles your source code to esm format. |
| 45 | + |
| 46 | +### `watch`: boolean |
| 47 | + |
| 48 | +Whether to watch for file changes or not. This is an optional option. The default value is `true`. |
| 49 | + |
| 50 | +### `outDir`: string |
| 51 | + |
| 52 | +The output directory to emit the production build to. This is an optional option. The default value is `dist`. |
| 53 | + |
| 54 | +### `envExtra`: boolean |
| 55 | + |
| 56 | +Extra env utilities to load. This allows you to load environment variables in different formats, like `Date`, `JSON`, `Boolean`, etc. This is an optional option. The default value is set to `true`. |
| 57 | + |
| 58 | +### `nodeOptions`: string[] |
| 59 | + |
| 60 | +Options to pass to Node.js. This is an optional option. The default value is `[]`. |
| 61 | + |
| 62 | +### `clearRestartLogs`: boolean |
| 63 | + |
| 64 | +Whether or not to clear default restart logs. This is an optional option. The default value is `true`. |
| 65 | + |
| 66 | +#### `minify`: boolean |
| 67 | + |
| 68 | +Whether or not to minify the production build. This is an optional option. The default value is `false`. |
| 69 | + |
| 70 | +### `sourcemap`: boolean | 'inline' |
| 71 | + |
| 72 | +Whether or not to include sourcemaps in the production build. This is an optional option. The default value is `false`. |
| 73 | + |
| 74 | +### `antiCrash`: boolean |
| 75 | + |
| 76 | +Whether or not to inject anti-crash script in the production build. This is an optional option. The default value is `true`. |
0 commit comments