Commands
compile
Compile Solidity contracts using Foundry
mega compile
The compile
command (also aliased as mega build
) compiles Solidity contracts using Foundry’s Forge under the hood.
Usage
Options
Mega CLI passes all options directly to Forge. Here are some commonly used options:
Option | Description |
---|---|
--names | Print compiled contract names |
--sizes | Print compiled non-test contract sizes |
--force | Clear the cache and recompile |
--optimize | Activate the Solidity optimizer |
--watch | Watch for changes and recompile |
The mega compile
command supports all options available in forge build
.
See the Forge documentation for a complete list.
Description
This command compiles your Solidity contracts using Foundry’s Forge compiler. It’s a wrapper around forge build
that ensures compatibility with the Mega CLI workflow while providing access to all of Forge’s powerful compilation options.
Examples
Basic compilation
Optimize contracts and show sizes
Watch for changes and recompile automatically
Force recompilation by clearing the cache
Related
Was this page helpful?