Configuration
Skittles is configured via a skittles.config.json or skittles.config.js file in your project root.
Config File
Create skittles.config.json:
{
"contractsDir": "contracts",
"outputDir": "build",
"typeCheck": true,
"optimizer": {
"enabled": true,
"runs": 200
}
}
Or use JavaScript for dynamic configuration:
module.exports = {
contractsDir: "contracts",
outputDir: "build",
typeCheck: true,
optimizer: {
enabled: process.env.NODE_ENV === "production",
runs: 200,
},
};
Options
| Option | Type | Default | Description |
|---|---|---|---|
contractsDir | string | "contracts" | Directory containing your TypeScript contract files |
outputDir | string | "build" | Directory where compiled artifacts are written |
typeCheck | boolean | true | Enable TypeScript type checking during compilation |
optimizer.enabled | boolean | false | Enable the Solidity optimizer |
optimizer.runs | number | 200 | Number of optimizer runs (higher = optimized for frequent calls) |
Default Behavior
If no config file is found, Skittles uses these defaults:
{
"contractsDir": "contracts",
"outputDir": "build",
"typeCheck": true,
"optimizer": {
"enabled": false,
"runs": 200
}
}
Optimizer
The optimizer setting controls the Solidity compiler's (solc) optimization pass. When enabled, it reduces gas costs for contract deployment and function execution.
enabled: false(default): No optimization. Faster compilation, larger bytecode.enabled: true: Optimizes the generated bytecode for gas efficiency.runs: How many times each function is expected to be called. Lower values optimize for deployment cost, higher values optimize for execution cost.200is a good default for most contracts.
{
"optimizer": {
"enabled": true,
"runs": 200
}
}
Incremental Compilation
Skittles uses SHA256 based incremental compilation. A cache file (.skittles-cache.json) is stored in the output directory and tracks:
- The hash of each source file
- The hash of all shared definitions (types, functions, constants)
On subsequent compilations:
- If a file has not changed and no shared definitions have changed, the cached artifacts are reused
- If a file changed, only that file is recompiled
- If any shared definition changed (e.g., a struct in
types.ts), all files that depend on shared definitions are recompiled
This keeps compilation fast even as your project grows. Use skittles clean to clear the cache and force a full recompilation.
TypeScript Configuration
Skittles reads TypeScript files directly using the TypeScript compiler API. You do not need a special tsconfig.json for Skittles, but having one gives you IDE support.
The skittles init command generates a tsconfig.json configured for contract development:
{
"compilerOptions": {
"target": "ES2022",
"module": "nodenext",
"moduleResolution": "nodenext",
"lib": ["ES2022"],
"strict": true,
"strictPropertyInitialization": false,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"outDir": "./dist",
"rootDir": "."
},
"include": ["contracts/**/*"],
"exclude": ["node_modules", "build", "dist"]
}
Key settings:
strictPropertyInitialization: falseis important because state variables are initialized by the Solidity runtime, not in a constructorincludeshould cover your contracts directoryoutDirandrootDirare only relevant if you also run the TypeScript compiler directly (not required for Skittles)