jbrantly/ts-jsx-loader

Gulp support?

Closed this issue · 2 comments

I just found this tool which is supper great!
I would like to know any plan to support gulp?

This project is specific to webpack. However, I actually implemented this approach first with gulp. It's very easy to do using gulp-replace.

Here is some old code of mine that did this. It would need to be changed slightly though to work. See the code in this project as a reference.

var gulp = require('gulp'),
    typescript = require('gulp-tsc'),
    replace = require('gulp-replace'),
    react = require('react-tools');

gulp.task('compile', function () {
    return gulp.src(['**/*.ts'])
        .pipe(replace(/React\.jsx\((\/\*((.|[\r\n])*?)\*\/)\)/gm, function (match, fullComment, commentContents) {
            return '('+ react.transform('/** @jsx React.DOM */' + commentContents).slice(21) + ')';
        }))
        .pipe(gulp.dest('dest/')) // typescript requires actual files on disk, not just in memory
        .pipe(typescript({ out: 'compiled.js' }))
        .pipe(gulp.dest('dest/'))
});

That is supper! I will try it out. Thanks so much!