Build Profiles
Build Profiles let you use different Solidity compiler configurations for different use cases. For example, you might use one Build Profile for running tests and another for deployment, each with settings optimized for that workflow.
Configuring a Build Profile
Section titled “Configuring a Build Profile”To configure a Build Profile, use this extended version of the solidity settings in your config:
import { defineConfig } from "hardhat/config";
export default defineConfig({ //... solidity: { profiles: { myProfile: { // This is a normal Solidity config, as explained in the previous guide } }
npmFilesToBuild: [ // ... npm files to build and emit artifacts ] },});Each Build Profile can use the full compiler configuration.
Built-in Build Profiles
Section titled “Built-in Build Profiles”Hardhat 3 always defines two Build Profiles:
default: used by most tasks when you don’t specify a profile, with settings optimized for development speed and experienceproduction: recommended for deployments, with the optimizer and Isolated Builds enabled by default
Using a solidity config without defining Build Profiles
Section titled “Using a solidity config without defining Build Profiles”If you define your Solidity config without explicitly defining Build Profiles, you’re actually configuring the default profile. This means the configuration shown in the previous guide applies to the default profile.
Choosing a Build Profile
Section titled “Choosing a Build Profile”You can use the --build-profile argument to choose which Build Profile to use when running Hardhat.
For example, to run your tests with the production profile:
npx hardhat test --build-profile productionpnpm hardhat test --build-profile productionyarn hardhat test --build-profile productionIf you don’t specify a profile, most tasks will use default, but each task can choose the profile that works best for its workflow. For example, when you deploy with Hardhat Ignition, it uses production by default.