An open API service indexing awesome lists of open source software.

https://github.com/btoo/truffle-contract-loader

Webpack loader for .sol files using truffle-compile
https://github.com/btoo/truffle-contract-loader

sol-files truffle webpack-loader

Last synced: about 2 months ago
JSON representation

Webpack loader for .sol files using truffle-compile

Awesome Lists containing this project

README

          

Webpack loader for importing .sol files as [Truffle](http://truffleframework.com/) contracts using [truffle-compile](https://github.com/trufflesuite/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](https://github.com/TiesNetwork/solidify) and then feeding the result to the compiler. Compiled contracts are stored in memory and cached.

First install the package:
```bash
yarn add truffle-contract-loader
```

Then insert this into your webpack config:
```javascript
// 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
}
}
}
}
}
// ...
]
// ...
}
// ...
}
```