Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
An explanation of how to share variables between Gulp and Grunt

Sharing variables between Gulp and Grunt

Gulp, while being a great build system, isn't perfect. Its plugin system is immature and not as full-featured as Grunt. I created gulp-grunt as a remedy for this problem, making it possible to import tasks from Grunt to gulp.

However, sometimes you want to use variables in both files. How? Well, use an accessory file to define all your variables, and import it from both.

In this gist is an example(a terrible one at that, but whatever) of importing stuff from an external file.

var paths = require('./paths');
module.exports = function(grunt) {
// Project configuration
pkg: grunt.file.readJSON('package.json'),
concat: {
'myproject': {
// may need to use grunt expansion
src: [paths.src],
dest: paths.dest + paths.destFile
// Default task
var gulp = require('gulp');
var concat = require('gulp-concat');
// Loading paths
var paths = require('./paths');
gulp.task('concat', function () {
return gulp.src(paths.src)
// I put all my paths in here
exports.src = 'src/js/**/*';
exports.dest = 'build/';
exports.destFile = 'concat.js';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment