# brick-asset

> Site CSS/JS generator for Brick.JS

Latest version **1.1.1** (published 2016-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install brick-asset
pnpm add brick-asset
yarn add brick-asset
bun add brick-asset
```

Provides the command `brick-asset`.

## 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.1.1 |
| Published | 2016-09-11 |
| First published | 2016-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | harttle |
| Maintainers | harttle |
| Keywords | Brick.JS, asset |

## Links

- npm: https://www.npmjs.com/package/brick-asset
- Repository: https://github.com/brick-js/brick-asset
- Homepage: https://github.com/brick-js/brick-asset#readme
- Issues: https://github.com/brick-js/brick-asset/issues
- npm.io page: https://npm.io/package/brick-asset

## Dependencies (6)

- [less](https://npm.io/package/less.md) ^2.7.1
- [debug](https://npm.io/package/debug.md) ^2.2.0
- [lodash](https://npm.io/package/lodash.md) ^4.12.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.3.5
- [commander](https://npm.io/package/commander.md) ^2.9.0
- [brick-less](https://npm.io/package/brick-less.md) 1.1.10

## Recent versions

- 1.1.1 (latest) — 2016-09-11
- 1.1.0 — 2016-05-23
- 1.0.9 — 2016-05-16
- 1.0.8 — 2016-05-12
- 1.0.7 — 2016-05-11
- 1.0.6 — 2016-05-10
- 1.0.4 — 2016-05-10
- 1.0.3 — 2016-05-10
- 1.0.2 — 2016-05-10
- 1.0.1 — 2016-05-10
- 1.0.0 — 2016-05-10

## README

# Asset Generator for Brick.JS

[![NPM version](https://img.shields.io/npm/v/brick-asset.svg?style=flat)](https://www.npmjs.org/package/brick-asset)
[![Build Status](https://travis-ci.org/brick-js/brick-asset.svg?branch=master)](https://travis-ci.org/brick-js/brick-asset)
[![Coverage Status](https://coveralls.io/repos/github/brick-js/brick-asset/badge.svg?branch=master)](https://coveralls.io/github/brick-js/brick-asset?branch=master)
[![Dependency manager](https://david-dm.org/brick-js/brick-asset.png)](https://david-dm.org/brick-js/brick-asset)

This article explains how to use `brick-asset` as a command line tool
(and as a NPM package).
For information about CSS Processors called by `brick-asset`, see:

* [brick-js/brick-less][brick-less]: LESS pre-processor for brick.js.
* brick-sass? All kind of contributions are wellcomed.

## Command Line Interface

### Install

```bash
npm install -g brick-asset
```

### Usage

Generate `"./public/site.js"` and `"./public/site.css"`:

```bash
brick-asset all
```

Only generate `./public/site.css`:

```bash
brick-asset css
```

Specify Brick.JS Module Root (default to `./bricks/`):

```bash
brick-asset all --root ./my-brick-modules
```

Specify output location:

```bash
# ./static/site.js, ./static/site.css
brick-asset all --output ./static

# ./static/js/main.js
brick-asset js --output ./static/js/main.js
```

For more details, see:

```bash
brick-asset --help
```

## Programmatically

### Usage

```javascript
var asset = require('brick-asset');
var promise = asset.src('./bricks');
promise
  .then(function(){
    asset.js().then(src => console.log(src));
    asset.css().then(src => console.log(src));
  });
```

### .src()

`.src()` load *bricks* in the specified directory. 

Returns a promise which will be resolved as brick Array.

### .js()

`.js()` generates the JS for all the *bricks* with a CommonJS loader.

Returns a promise which will be resolved as a String of JavaScript source.

### .css()

`.css()` generates the modularized CSS for all the *bricks*.

Returns a promise which will be resolved as a String of CSS source.

## Gulp Task

Here's a [Gulp][gulp] file generating `public/site.css` and `public/site.js`:

```javascript
var asset = require('brick-asset');
var file = require('gulp-file');

gulp.task('js', function(cb) {
    asset.src('./bricks')
        .then(x => asset.js())
        .then(css => file('site.js', css, {src: true})
            .pipe(gulp.dest('public'))
            .on('finish', cb));
});

gulp.task('css', function(cb) {
    asset.src('./bricks')
        .then(x => asset.css())
        .then(css => file('site.css', css, {src: true})
            .pipe(gulp.dest('public'))
            .on('finish', cb));
});
```

[brick-less]: https://github.com/brick-js/brick-less
[gulp]: http://gulpjs.com/

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