Created
February 13, 2015 19:53
-
-
Save dandonahoe/38aae3fde2c134532bba to your computer and use it in GitHub Desktop.
Laravel 5 Elixir Gulp file with Browserify and Reactify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var elixir = require('laravel-elixir'); | |
var browserify = require('browserify'); | |
var source = require('vinyl-source-stream'); | |
var reactify = require('reactify'); | |
// Create a new command for Laravel Elixir that will browserify and Reactify | |
elixir.extend('reactifyBrowserifyElixir', function(inputFile, inputFileName, outputDirectory) { | |
gulp.task('browserify_and_reactify', function() { | |
var b = browserify(); | |
b.transform(reactify); | |
b.add(inputFile); | |
return b.bundle() | |
.pipe(source(inputFileName)) | |
.pipe(gulp.dest(outputDirectory)); | |
}); | |
return this.queueTask('browserify_and_reactify'); | |
}); | |
// Now include the new Elixir command in the standard build process | |
elixir(function(mix) { | |
mix.reactifyBrowserifyElixir('./resources/assets/js/main.js', 'main.js', 'public/js/') | |
.version(['public/js/main.js']); | |
// after version() is done, the final js file is | |
// output to /public/build/js/main.js | |
// which can be added to your blade template via | |
// <script src="{{ elixir('js/main.js') }}"></script> | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is located in the standard Laravel 5 /resources/assets/js | |
var React = require('react'); | |
var viewTest = require('./zomg.jsx'); | |
React.renderComponent(viewTest(), document.getElementById('content')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is located in the standard Laravel 5 /resources/assets/js | |
var React = require('react'); | |
var viewTest = React.createClass({ | |
render: function(){ | |
return ( | |
<div> | |
Boo Yah | |
</div> | |
); | |
} | |
}); | |
module.exports = viewTest; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment