/sol-merger

Merges all imports into single file for solidity contracts

Primary LanguageJavaScriptBSD 2-Clause "Simplified" LicenseBSD-2-Clause

Build status

Build status

USAGE

Right now it only works with solidity files that are in node_modules or relative to your solidity file.

Simple usage:

npm i --save-dev sol-merger

Then add following line to your package.json.

{
  "scripts": {
    "build-contracts": "sol-merger \"./contracts/*.sol\" ./build"
  },
}

This will allow you to use npm run build-contracts in your project directory.

Note that contracts glob should be surrounded with "

If no output file specified then output file will be created at the same directory and appended with _merged (by default), i.e. MyContract_merged.sol. You can also change this behaviour by specifying --append option:

sol-merger --append _me "./contracts/*.sol"
sol-merger -a _me "./contracts/*.sol"

You may need to use npm run to invoke the program standalone, as in npm run sol-merger.

You can also get help via --help command

sol-merger -h
sol-merger --help

More info about glob available at node-glob repository

Plugin for VSCode

I created a plugin for VSCode so you can use it instead of sol-merger: Solidity Contracts Merger.

Hope you will like it.