# truffle-default-builder

> Default builder for Truffle dapps

Latest version **2.0.0** (published 2017-01-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install truffle-default-builder
pnpm add truffle-default-builder
yarn add truffle-default-builder
bun add truffle-default-builder
```

## 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 | 2.0.0 |
| Published | 2017-01-31 |
| First published | 2016-01-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 19 |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 18 |
| Author | Tim Coulter |
| Maintainers | tcoulter |

## Links

- npm: https://www.npmjs.com/package/truffle-default-builder
- Repository: https://github.com/ConsenSys/truffle-default-builder
- Homepage: https://github.com/ConsenSys/truffle-default-builder#readme
- Issues: https://github.com/ConsenSys/truffle-default-builder/issues
- npm.io page: https://npm.io/package/truffle-default-builder

## Dependencies (19)

- [cpr](https://npm.io/package/cpr.md) ^1.0.0
- [temp](https://npm.io/package/temp.md) ^0.8.3
- [web3](https://npm.io/package/web3.md) ^0.16.0
- [async](https://npm.io/package/async.md) ^1.5.2
- [colors](https://npm.io/package/colors.md) ^1.1.2
- [lodash](https://npm.io/package/lodash.md) ^4.0.0
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [bluebird](https://npm.io/package/bluebird.md) ^3.1.1
- [node-sass](https://npm.io/package/node-sass.md) ^3.4.2
- [uglify-js](https://npm.io/package/uglify-js.md) ^2.6.1
- [babel-core](https://npm.io/package/babel-core.md) ^6.4.0
- [browserify](https://npm.io/package/browserify.md) ^13.0.1
- [coffee-script](https://npm.io/package/coffee-script.md) ^1.10.0
- [truffle-contract](https://npm.io/package/truffle-contract.md) ^1.1.6
- [babel-preset-react](https://npm.io/package/babel-preset-react.md) ^6.3.13
- [babel-preset-es2015](https://npm.io/package/babel-preset-es2015.md) ^6.3.13
- [babel-preset-stage-2](https://npm.io/package/babel-preset-stage-2.md) ^6.3.13
- [babel-plugin-syntax-jsx](https://npm.io/package/babel-plugin-syntax-jsx.md) ^6.3.13
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) ^6.4.0

## Recent versions

- 2.0.0 (latest) — 2017-01-31
- 1.0.3 — 2016-08-23
- 1.0.2 — 2016-08-22
- 1.0.1 — 2016-05-31
- 1.0.0 — 2016-05-24
- 0.0.9 — 2016-02-25
- 0.0.8 — 2016-02-23
- 0.0.7 — 2016-02-17
- 0.0.6 — 2016-01-29
- 0.0.5 — 2016-01-28
- 0.0.4 — 2016-01-20
- 0.0.3 — 2016-01-20
- 0.0.2 — 2016-01-20
- 0.0.1 — 2016-01-20

## README

# truffle-default-builder

This is the build system that came standard with Truffle 1.0 and 2.0. For Truffle 3.0, it has been separated out as its own module and is no longer shipped as the default.

# Features

The default builder comes with a few standard niceties meant to get you started quickly:

* Automatic bootstrapping of your application within the browser, importing your compiled contract artifacts, deployed contract information and Ethereum client configuration automatically.
* Inclusion of recommended dependencies, including [web3](https://github.com/ethereum/web3.js/tree/master) and [Ether Pudding](https://github.com/ConsenSys/ether-pudding).
* Support for ES6 and JSX built-in.
* SASS support for manageable CSS.
* And UglifyJS support for creating minified versions of your Javascript assets.

# Configuration

The default builder gives you complete control over how you want to organize your files and folders, but the default directory structure looks like this:

```none
app/
- javascripts/
  - app.js
- stylesheets/
  - app.css
- images/
- index.html
```

It's corresponding configuration within your [project configuration](/docs/advanced/configuration) looks very similar:

```javascript
{
  "build": {
    // Copy ./app/index.html (right hand side) to ./build/index.html (left hand side).
    "index.html": "index.html",

    // Process all files in the array, concatenating them together
    // to create a resultant app.js
    "app.js": [
      "javascripts/app.js"
    ],

    // Process all files in the array, concatenating them together
    // to create a resultant app.css
    "app.css": [
      "stylesheets/app.scss"
    ],

    // Copy over the whole directory to the build destination.
    "images/": "images/"
  }
}
```

This configuration describes "targets" (left hand side) with files, folders and arrays of files that make up the targets' contents (right hand side). Each target will be produced by processing the files on the right hand side based on their file extension, concatenating the results together and then saving the resultant file (the target) into the build destination. Where a string is specified on the right hand side instead of an array, that file will be processed, if needed, and then copied over directly. If the string ends in a "/", it will be interpreted as a directory and the directory will be copied over without further processing. All paths specified on the right hand side are relative to the `app/` directory.

You can change this configuration and directory structure at any time. You aren't required to have a `javascripts` and `stylesheets` directory, for example, but make sure you edit your configuration accordingly.

**Special note:** If you want the default builder to bootstrap your application on the frontend, make sure you have a build target called `app.js` which the default builder can append code to. It will not bootstrap your application with any other filename.

# Usage in Truffle 3.0

To use in Truffle 3.0, first install the default builder as a dependency of your project:

```
$ npm install truffle-default-builder --save
```

Next, use the default builder within your Truffle configuration by `require`'ing it and passing a new instance of the builder into Truffle:

```javascript
var DefaultBuilder = require("truffle-default-builder");

module.exports = {
  build: new DefaultBuilder({
    "index.html": "index.html",
    "app.js": [
      "javascripts/app.js"
    ],
    "app.css": [
      "stylesheets/app.css"
    ],
    "images/": "images/"
  }),
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    }
  }
};
```

# Build Artifacts

Your build artifacts are saved within the `./build` directory, along side compiled deployed contract artifacts in `./build/contracts`.

# Considerations

The default builder is easy to use for most projects, and allows you to quickly get started. However, it has some drawbacks:

* It doesn't currently support `import`, `require`, etc., provided to you by tools like Browserify, Webpack, and CommonJS, making dependency management harder than it should be.
* It's a custom build system and doesn't easily integrate with other popular build systems.
* It is extensible, but again, using custom methods and APIs.

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