GithubHelp home page GithubHelp logo

tinajs / gulp-mina Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 63 KB

:oden: split/precompile mina single-file-component

License: MIT License

JavaScript 100.00%
gulp mina single-component-file mina-sfc weapp wechat-mini-program

gulp-mina's Introduction

gulp-mina

๐Ÿข split/precompile mina single-file-component

npm license PRs Welcome

Install

npm install --save-dev @tinajs/gulp-mina

Usage

Precompile mina single-file-component library

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)

Split mina single-file-component to a group of files (wxml, wxss, json and js)

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

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

License

MIT ยฉ yelo, 2017 - present

gulp-mina's People

Contributors

imyelo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

wagnlinzh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.