# @tinajs/gulp-mina

> split/precompile mina single-file-component

Latest version **0.1.2** (published 2018-03-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tinajs/gulp-mina
pnpm add @tinajs/gulp-mina
yarn add @tinajs/gulp-mina
bun add @tinajs/gulp-mina
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2018-03-15 |
| First published | 2017-11-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | yelo |
| Maintainers | yelo |

## Links

- npm: https://www.npmjs.com/package/@tinajs/gulp-mina
- Repository: https://github.com/tinajs/gulp-mina
- Homepage: https://github.com/tinajs/gulp-mina#readme
- Issues: https://github.com/tinajs/gulp-mina/issues
- npm.io page: https://npm.io/package/@tinajs/gulp-mina

## Dependencies (7)

- [gulp](https://npm.io/package/gulp.md) ^3.9.1
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.1
- [through2](https://npm.io/package/through2.md) ^2.0.3
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.8
- [replace-ext](https://npm.io/package/replace-ext.md) ^1.0.0
- [event-stream](https://npm.io/package/event-stream.md) ^3.3.4
- [@tinajs/mina-sfc](https://npm.io/package/@tinajs/mina-sfc.md) ^0.2.0

## Recent versions

- 0.1.2 (latest) — 2018-03-15
- 0.1.1 — 2018-01-15
- 0.1.0 — 2017-11-28

## README

# gulp-mina
> :oden: split/precompile mina single-file-component

[![npm](https://img.shields.io/npm/v/@tinajs/gulp-mina.svg?style=flat-square)](https://www.npmjs.com/package/@tinajs/gulp-mina)
[![license](https://img.shields.io/github/license/tinajs/gulp-mina.svg?style=flat-square)](./LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

## Install
```bash
npm install --save-dev @tinajs/gulp-mina
```

## Usage
### Precompile mina single-file-component library
```javascript
const gulp = require('gulp')
const babel = require('gulp-babel')
const mina = require('@tinajs/gulp-mina')

gulp.task('default', () => {
  return gulp.src('src/**/*.mina')
    .pipe(mina({
      script: (stream) => stream.pipe(babel({ presets: ['env'] })),
    }))
    .pipe(gulp.dest('dist'))
})
```

[Example (more complicated)](./examples/precompile-mina-library)

### Split mina single-file-component to a group of files (``wxml``, ``wxss``, ``json`` and ``js``)
```javascript
const gulp = require('gulp')
const babel = require('gulp-babel')
const mina = require('@tinajs/gulp-mina')
gulp.task('default', ['clean'], () => {
  return gulp.src('src/**/*.mina')
    .pipe(mina.split({
      script: (stream) => stream.pipe(babel({ presets: ['env'] })),
    }))
    .pipe(gulp.dest('dist'))
})
```

[Example](./examples/split-to-a-group-of-files)

## API
### mina([mapping])
Separate mina-sfc to multiple streams, and pipe the recombined results down. 

#### mapping
Type: ``Object``  
Default: {}  

Each separated streams of mina-sfc file will be passed to these mapping functions.

##### script
Type: ``Function``  

Receive the stream of ``<script>`` part as a ``.js`` file.

##### config
Type: ``Function``  

Receive the stream of ``<config>`` part as a ``.json`` file.

##### style
Type: ``Function``  

Receive the stream of ``<style>`` part as a ``.wxss`` file.

##### template
Type: ``Function``  

Receive the stream of ``<template>`` part as a ``.wxml`` file.

### mina.split([mapping])
Just like ``mina([mapping])``, but pipe separated mina-sfc as multiple files to the downstream.

## Related
- [gulp](https://github.com/gulpjs/gulp)
- [mina-sfc](https://github.com/tinajs/mina-sfc)

## License
MIT &copy; [yelo](https://github.com/imyelo), 2017 - present

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