truffle-contract-loader
v1.0.7
Published
Webpack loader for .sol files using truffle-compile
Downloads
7
Readme
Webpack loader for importing .sol files as Truffle contracts using truffle-compile (and by extension, its solc and Solidity version pragma).
Additionally, this loader will refrain from creating any pre-compiled contract artifact files. Dependency trees are resolved by first merging the files and then feeding the result to the compiler. Compiled contracts are stored in memory and cached.
First install the package:
yarn add truffle-contract-loader
Then insert this into your webpack config:
// webpack 2+
module.exports = {
// ...
module: {
// ...
rules: [
// ...
{
test: /\.sol$/,
use: {
loader: 'truffle-contract-loader',
options: {
contracts_directory: './contracts', // required - the directory containing all your Solidity contracts
solc: { // solc compiler options (optional) - defaults to the following (more information found here: http://solidity.readthedocs.io/en/develop/using-the-compiler.html)
optimizer: {
enabled: true,
runs: 200
}
}
}
}
}
// ...
]
// ...
}
// ...
}