改变Laravel的Gulp/Elixir`watch`任务

igo*_*s07 8 laravel semantic-ui gulp gulp-watch laravel-5

我想在我的新项目中使用Laravel的Elixir和Semantic UI.

在Semantic UI文档中,他们建议如何将gulp任务包含在当前项目的gulpfile中.在Laravel,他们(简要地)建议如何扩展Elixir.但是如何在watch命令中包含另一个gulp任务?

目前我正在运行gulp watch watch-ui,但我想将watch-ui任务包括在内watch.可能吗?

这是我目前的gulpfile.js:

var gulp     = require('gulp');
var elixir   = require('laravel-elixir');
var semantic = {
  watch: require('./resources/assets/semantic/tasks/watch'),
  build: require('./resources/assets/semantic/tasks/build')
};

gulp.task('watch-ui', semantic.watch);
gulp.task('build-ui', semantic.build);

elixir(function(mix) {
  mix.task('build-ui');
});
Run Code Online (Sandbox Code Playgroud)

All*_*sen 3

如果我正确理解您的问题,您想在语义 UI 任务中添加一些内容。然而,它们从未真正定义任务,而只是定义可以分配给任务的函数。

您实际上不能在semantic watch任务中包含任何内容,除非您想修补文件,但您可以添加两个监视任务并确保它们都运行。

以下代码应该使您能够执行您需要的操作:

var gulp     = require('gulp');
var elixir   = require('laravel-elixir');
var semantic = {
  watch: require('./resources/assets/semantic/tasks/watch'),
  build: require('./resources/assets/semantic/tasks/build')
};

// Define a task for the semantic watch function.
gulp.task('semantic-watch', semantic.watch);

// Define the main watch task, that is depended on the semantic-watch, this will run both watch tasks when you run this one.
gulp.task('watch', ['semantic-watch'], function() {
    // Do your own custom watch logic in here.
});

gulp.task('build-ui', semantic.build);

elixir(function(mix) {
  mix.task('build-ui');
});
Run Code Online (Sandbox Code Playgroud)

您可以在此处查看 Semantic UI 实际上如何定义其watch任务应使用监视功能: https: //github.com/Semantic-Org/Semantic-UI/blob/master/gulpfile.js#L46