Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt config with es6

It is possible to write grunt config files in es6 like this?

//Gruntfile.js
module.exports = function (grunt) {
  var arr = [1,2,3];
  arr.forEach(val => {
    ...
  });
  ...
}
like image 472
mqklin Avatar asked Jul 28 '15 06:07

mqklin


Video Answer


1 Answers

One possible way to do this painlessly is to use Babel's babel-register module like this:

Installation:

npm install babel-register --save-dev

.babelrc:

{
    presets: ["es2015"]
}

Gruntfile.js:

require('babel-register')

module.exports = require('./Gruntfile.es').default

Gruntfile.es

export default function(grunt) {
    grunt.initConfig({})
}
like image 59
marco-a Avatar answered Sep 19 '22 11:09

marco-a