I´m trying to automate as much as I could my truffle process and I wanna export the contracts during the "truffle migrate" command to two separate folders.

Imagine that I have a frontend and backend that use the smart contracts created by truffle.

I changed my truffle-config.js with "contracts_build_directory", but I want to export all contracts to two folders at the same time.

Is this possible? Any ideas?


1 Answer 1


You can write your own shell script to copy the file into the folder you want. Then pack it into a script along with truffle migrate.


postMigration() {
    cp contract.json path/to/another/folder/contract.json

truffle migrate
  • Thanks. I was wondering that I could do it with truffle.
    – gustavomr
    Commented Feb 25, 2022 at 12:23
  • Definitely yes, as truffle migration file is the javascript file, we can achieve the same result using the js. You can read it more here
    – PySoL
    Commented Feb 25, 2022 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.