solc loader for webpack
Compiles .sol
with JavaScript Solidity compiler and returns JavaScript objects with Application Binary Interface (ABI) and bytecode ready to be deployed on to Ethereum.
Ideally to be used with web3-loader for automatic deployment and ready-to-use JavaScript instances of smart contracts.
Installation
npm install solc-loader --save-dev
Usage
var SmartContracts = require('solc!./SmartContracts.sol');
Example webpack config
At your project's webpack.config.js
:
module.exports = {
module: {
loaders: [
{
test: /\.sol$/,
loaders: ['solc']
]
}
}
Recommended usage with web3-loader
solc-loader
would be much sweeter if used along web3-loader
. web3-loader
automatically deploys new/changed contracts on to Ethereum and returns ready-to-use JavaScript instances of smart contracts.
At your project's webpack.config.js
:
module.exports = {
module: {
loaders: [
{
test: /\.sol$/,
loaders: ['web3', 'solc']
]
}
}
Optimization
solc-loader
is set to compile with optimization turned on.
To turn off optimization, pass optimize=0
via either query or loader config with the key solcLoader
.
Query style
loaders: ['solc?optimize=0']
loader: 'solc?optimize=0'
Config style
module.exports = {
solcLoader: {
optimize: 0
}
}
License
MIT · U-Zyn Chua (@uzyn)