in general, truffle compiles all the contracts inside contracts
folder within the current directory (the directory your terminal is showing).
running the truffle compile
command in your truffle project directory will only compile the contracts in the current contracts
folder, depending on the compiler version in truffle-config.js
in the same directory.
compilers: {
solc: {
version: "0.4.24", // Fetch exact version from solc-bin (default: truffle's version)
docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
settings: { // See the solidity docs for advice about optimization and evmVersion
optimizer: {
enabled: false,
runs: 200
},
evmVersion: "byzantium"
}
}
}
and when you want to use the truffle migrate
command, you can give it a specific blockchain to connect to, like truffle migrate --network myNetwork
:
networks: {
myNetwork: { // default with truffle unbox is 7545, but we can use develop to test changes, ex. truffle migrate --network develop
host: "127.0.0.1",
port: 8545,
network_id: "*"
}
}
so you can configure each truffle-config.js
file for different projects with different compilers and blockchains.
like this, you can have different virtual blockchains like ganache
and truffle develop
etc, and configure the truffle-config.js
of each of your projects to connect the one of them. this way you can have completely separate projects running at the same time, let alone the different truffle compilers