e-jigsaw / gulp-riot

gulp plugin for riot
105 stars 10 forks source link

Hi, I wanna know how to compile some directory's tags into one js #69

Closed dongtong closed 8 years ago

dongtong commented 8 years ago

Hi, I wanna know how to compile some directory's tags into one js.

Thanks a lot

afwilliams commented 8 years ago

Hello, I am using riotify for compile my tags in one js file.

var gulp = require('gulp');
var browserify = require('browserify');
var riotify = require('riotify');
var source = require('vinyl-source-stream');

gulp.task('browserify', function () {
    return browserify({
        debug: true,
        entries: ['./scripts/main.js'],
        transform: [riotify]
    }).bundle()
        .pipe(source('main.bundle.js'))
        .pipe(gulp.dest('./dist/'));
});

gulp.task('default', ['browserify']);

this plugin use browserify for generate js file and you have the feature require for do call of components.

var riot = require('riot');
require('../tags/sample.tag');
riot.mount('sample');

I Like riotify

e-jigsaw commented 8 years ago

@dongtong Hi

I use gulp-concat in my project.

gulp.task('riot', ()=> {
  gulp.src('directories')
      .pipe(riot())
      .pipe(concat('index.js'))
      .pipe(gulp.dest('dest'))
})

It is also good to use browserify as @afwilliams says.

Thanks

dongtong commented 8 years ago

@e-jigsaw Yep, I used same solution as you pointed. BTW, Thanks a lot