# truffle-contract-loader

> Webpack loader for .sol files using truffle-compile

Latest version **1.0.7** (published 2017-10-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install truffle-contract-loader
pnpm add truffle-contract-loader
yarn add truffle-contract-loader
bun add truffle-contract-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2017-10-31 |
| First published | 2017-10-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | btoo |
| Keywords | truffle, solidity, webpack, ethereum |

## Links

- npm: https://www.npmjs.com/package/truffle-contract-loader
- Repository: https://github.com/btoo/truffle-contract-loader
- Homepage: https://github.com/btoo/truffle-contract-loader#readme
- Issues: https://github.com/btoo/truffle-contract-loader/issues
- npm.io page: https://npm.io/package/truffle-contract-loader

## Dependencies (5)

- [semver](https://npm.io/package/semver.md) ^5.3.0
- [loader-utils](https://npm.io/package/loader-utils.md) ^1.1.0
- [solidity-parser](https://npm.io/package/solidity-parser.md) ^0.3.0
- [truffle-compile](https://npm.io/package/truffle-compile.md) ^3.0.2
- [truffle-contract](https://npm.io/package/truffle-contract.md) ^3.0.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2017-10-31
- 1.0.6 — 2017-10-28
- 1.0.5 — 2017-10-27
- 1.0.4 — 2017-10-26
- 888.0.0 — 2017-10-25
- 0.0.8 — 2017-10-25
- 0.0.7 — 2017-10-25
- 0.0.6 — 2017-10-24
- 0.0.5 — 2017-10-24
- 0.0.4 — 2017-10-24
- 0.0.3 — 2017-10-24
- 0.0.2 — 2017-10-23
- 0.0.1 — 2017-10-23
- 1.0.3 — 2017-10-23
- 1.0.2 — 2017-10-23
- … 2 more at https://npm.io/package/truffle-contract-loader/versions

## 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
              }
            }
          }
        }
      }
      // ...
    ]
    // ...
  }
  // ...
}
```

---
_Source: https://npm.io/package/truffle-contract-loader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
