使用 laravel 长生不老药设置 browserify 观察者

setup browserify watcher with laravel elixir

我正在尝试添加一个 browserify 观察器来自动编译我对我的一些反应组件所做的更改,但观察器不起作用...

这让我抓狂!我不明白为什么这些任务运行器必须如此复杂并且没有标准API!

任何帮助将不胜感激!

无论如何这是我的 browserify 任务

// react components
elixir(function(mix) {
    mix.browserify(assetsJsDir + "components/*.jsx");
});

这是全部gulpfile.js

var elixir = require('laravel-elixir');

elixir.config.js.browserify.watchify.enabled = true;

var bowerDir = './bower_components/';
var assetsJsDir = './resources/assets/js/';
var assetsCssDir = './resources/assets/css/';

/*
 |--------------------------------------------------------------------------
 | Elixir Asset Management
 |--------------------------------------------------------------------------
 |
 | Elixir provides a clean, fluent API for defining some basic Gulp tasks
 | for your Laravel application. By default, we are compiling the Sass
 | file for our application, as well as publishing vendor resources.
 |
 */

// styles
elixir(function(mix) {
    mix.sass('app.scss')
    .version(['css/app.css']);
});

// external libs js files
elixir(function(mix) {
    mix.scripts([
        bowerDir + 'jquery/dist/jquery.min.js',
        bowerDir + 'bootstrap/dist/js/bootstrap.min.js',
        bowerDir + 'react/react.js',
        bowerDir + 'react/react-dom.js',
        bowerDir + 'lodash/dist/lodash.min.js',
    ], 'public/js/extlibs.js', ".")
    .version(['js/extlibs.js']);
});

// react components
elixir(function(mix) {
    mix.browserify(assetsJsDir + "components/*.jsx");
});

// my libs js files
elixir(function(mix) {
    mix.scripts([
        assetsJsDir + "pagevars.js",
        assetsJsDir + "traininglog-lib.js",
        assetsJsDir + "session_new.js",
    ], "public/js/app.js")
    .version(['js/app.js']);
});

我用错了方法。

我想做的是

elixir(function(mix) {
    mix.babel([
        assetsJsDir + "components/*.jsx"
    ], "public/js/components.js")
    .version("js/components.js");
});

现在可以了