LoginSignup
5
5

More than 5 years have passed since last update.

gulpからgruntのタスクを直接実行する

Last updated at Posted at 2015-10-29

やりたいこと

  • grunt向けにしか提供されていないタスクをgulpから実行したい (つらい)

やり方1 - gulp-grunt

gulp-grunt という、gruntタスクをgulpから実行できるようにするツールを使う。

Gruntfile.js は別に用意する。

gulpfile.js
require("gulp-grunt")(gulp);

gulp.task("some-task", ["grunt-<gruntのタスク名>"]);

やり方2 - gruntのAPIを直接叩く

gruntのAPIをgulpfile内で直接叩いてタスクを実行する。
こちらのほうが自由度が高い。

gulpfile.js
var gulp = require("gulp");

grunt.task.init = function() {};

// Gruntfile.jsっぽいこと
grunt.initConfig({
  // タスク設定...
});
grunt.loadNpmTasks("<npmのタスク>");

gulp.task("some-task", function (done) {
  grunt.tasks(["<gruntのタスク名>"], {}, done);
});

参考

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5