Forked from dandonahoe/ Laravel 5 Elixir Gulp file with Browserify and Reactify
Last active
April 8, 2016 12:06
-
-
Save amonger/bf4fab5189404defa6e29d723e4218b2 to your computer and use it in GitHub Desktop.
Laravel 5 Elixir Gulp file with Browserify and Reactify
This file contains hidden or 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 hidden or 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'); | |
var Task = Elixir.Task; | |
// Create a new command for Laravel Elixir that will browserify and Reactify | |
elixir.extend('reactifyBrowserifyElixir', function(inputFile, inputFileName, outputDirectory) { | |
new Task('browserify_and_reactify', function() { | |
var b = browserify(); | |
b.transform(reactify); | |
b.add(inputFile); | |
return b.bundle() | |
.pipe(source(inputFileName)) | |
.pipe(gulp.dest(outputDirectory)); | |
}); | |
}); | |
// 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 hidden or 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 hidden or 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