railsware / bozon

🛠 Command line tool for building, testing and publishing modern Electron applications
MIT License
758 stars 52 forks source link

React implementation #43

Closed p1nox closed 7 years ago

p1nox commented 7 years ago

In case I want to use React, in order to use http://reactdesktop.js.org , I just need to add a gulp recipe to transpile jsx files right? Apart from installing needed packages in app/package.json I guess.

This is my gulpfile.js:

require('bozon/lib/tasks');
var bozon = require('bozon/lib/bozon');
var jsx = require('gulp-jsx');

bozon.buildTaskBefore('scripts:renderer', 'scripts:jsx', function() {
  return bozon.src('javascripts/scripts/**/*.jsx').pipe(jsx({
    factory: 'React.createClass'
  })).on('error', function(e) { console.log(e); }).pipe(bozon.dest('javascripts/renderer'));
});

Using https://github.com/alexmingoia/gulp-jsx, but it doesn't work, no files are generated in javascripts/renderer.

p1nox commented 7 years ago

Nvm, I found the problem I had while creating files, I'm using gulp directly instead of using bozon. In case someone want to implement React, here you go:

require('bozon/lib/tasks');

var gulp = require('gulp');
var bozon = require('bozon/lib/bozon');
var babel = require('gulp-babel');

bozon.buildTaskBefore('scripts:renderer', 'scripts:jsx', function() {
  return bozon.src('javascripts/src/**/*.js')
    .pipe(babel({
        presets: ['es2015', 'react']
    }))
    .pipe(print())
    .pipe(gulp.dest('./app/javascripts/renderer/dist'));
});

And of course files are generated in app/javascripts/renderer/dist, and I'm putting source files in app/javascripts/src.