29.07.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Laravel Elixir 234<br />

.<br />

Calling Existing Gulp Tasks<br />

If you need to call an existing Gulp task from Elixir, you may use the task method. As an example,<br />

imagine that you have a Gulp task that simply speaks a bit of text when called:<br />

1 gulp.task('speak', function() {<br />

2 A> var message = 'Tea...Earl Grey...Hot';<br />

3 A><br />

4 A> gulp.src('').pipe(shell('say ' + message));<br />

5<br />

6 });<br />

If you wish to call this task from Elixir, use the mix.task method and pass the name of the task as<br />

the only argument to the method:<br />

1 elixir(function(mix) {<br />

2 A> mix.task('speak');<br />

3<br />

4 });<br />

Custom Watchers<br />

If you need to register a watcher to run your custom task each time some files are modified, pass a<br />

regular expression as the second argument to the task method:<br />

1 elixir(function(mix) {<br />

2 A> mix.task('speak', 'app/**/*.php');<br />

3<br />

4 });<br />

Writing Elixir Extensions<br />

If you need more flexibility than Elixir’s task method can provide, you may create custom Elixir<br />

extensions. Elixir extensions allow you to pass arguments to your custom tasks. For example, you<br />

could write an extension like so:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!