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
- Host: GitHub
- URL: https://github.com/btoo/truffle-contract-loader
- Owner: btoo
- Created: 2017-10-24T00:51:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-31T20:43:54.000Z (over 8 years ago)
- Last Synced: 2026-04-06T09:33:58.185Z (2 months ago)
- Topics: sol-files, truffle, webpack-loader
- Language: JavaScript
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
}
}
}
}
}
// ...
]
// ...
}
// ...
}
```