国产chinesehdxxxx野外,国产av无码专区亚洲av琪琪,播放男人添女人下边视频,成人国产精品一区二区免费看,chinese丰满人妻videos

Custom Tasks and Extensions

2018-02-24 15:52 更新

Sometimes, you'll want to hook your own Gulp tasks into Elixir. Perhaps you have a special bit of functionality that you'd like Elixir to mix and watch for you. No problem!

As an example, imagine that you have a general task that simply speaks a bit of text when called.

gulp.task("speak", function() {
    var message = "Tea...Earl Grey...Hot";

    gulp.src("").pipe(shell("say " + message));
});

Easy enough. From the command line, you may, of course, call gulp speak to trigger the task. To add it to Elixir, however, use the mix.task() method:

elixir(function(mix) {
    mix.task('speak');
});

That's it! Now, each time you run Gulp, your custom "speak" task will be executed alongside any other Elixir tasks that you've mixed in. To additionally register a watcher, so that your custom tasks will be re-triggered each time one or more files are modified, you may pass a regular expression as the second argument.

elixir(function(mix) {
    mix.task('speak', 'app/**/*.php');
});

By adding this second argument, we've instructed Elixir to re-trigger the "speak" task each time a PHP file in the "app/" directory is saved.

For even more flexibility, you can create full Elixir extensions. Using the previous "speak" example, you may write an extension, like so:

var gulp = require("gulp");
var shell = require("gulp-shell");
var elixir = require("laravel-elixir");

elixir.extend("speak", function(message) {

    gulp.task("speak", function() {
        gulp.src("").pipe(shell("say " + message));
    });

    return this.queueTask("speak");

 });

請注意我們 擴增( extend ) Elixir 的 API 時所使用的第一個參數,稍后我們需要在 Gulpfile 中使用它,以及建立 Gulp 任務所使用的回調函數。

如果你想要讓你的自定義任務能被監(jiān)控,只要在監(jiān)控器注冊就行了。

this.registerWatcher("speak", "app/**/*.php");

這行程序的意思是指,當符合正則表達式 app/*/.php 的文件一經修改,就會觸發(fā) message 任務。

很好!接著你可以將這行程序寫在 Gulpfile 的頂端,或者將它放到自定義任務的文件里。如果你選擇后者,那么你必須將它加載至你的 Gulpfile,例如:

require("./custom-tasks")

大功告成!最后你只需要將他們結合。

elixir(function(mix) {
    mix.speak("Tea, Earl Grey, Hot");
});

加入之后,每當你觸發(fā) Gulp,Picard 就會要求一些茶。

以上內容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號