Question

I want to write my Gruntfile.js with livescript.

I've done Gruntfile.js and Gruntfile.coffee which both work out of the box

Gruntfile.ls should work... right?

I've seen a few Gruntfile.ls online or does it need to be compiles (other than a .coffee version)?

Livescript

(Error when calling $ grunt)

A valid Gruntfile could not be found. Please see the getting started guide for
more information on how to configure grunt: http://gruntjs.com/getting-started
Fatal error: Unable to find Gruntfile.

Gruntfile.ls

#global module:false

module.exports = (grunt) ->

  # Project configuration.
  grunt.init-config {}=

    meta:
      version: \0.0.1

    livescript:
      src:
        files:
          "build/js/main.js": "src/scripts/main.ls"

    watch:
     livescript:
        files: <[src/scripts/**/*.ls]>
        tasks: <[livescript]>
        options: {+livereload}

  # load tasks
  grunt.loadNpmTasks \grunt-livescript
  grunt.loadNpmTasks \grunt-contrib-watch

  # register tasks
  grunt.registerTask \default, <[livescript]>

compiled:

(works when calling $ grunt)

Gruntfile.js

module.exports = function(grunt){
  grunt.initConfig({
    meta: {
      version: '0.0.1'
    },
    livescript: {
      src: {
        files: {
          "build/js/main.js": "src/scripts/main.ls"
        }
      }
    },
    watch: {
      livescript: {
        files: ['src/scripts/**/*.ls'],
        tasks: ['livescript'],
        options: {
          livereload: true
        }
      }
    }
  });
  grunt.loadNpmTasks('grunt-livescript');
  grunt.loadNpmTasks('grunt-contrib-watch');
  return grunt.registerTask('default', ['livescript']);
};
Was it helpful?

Solution

Use this as your Gruntfile.js:

require('LiveScript');

module.exports = function (grunt) {
    require('./Gruntfile.ls')(grunt);
}

Requires the LiveScript package from npm.

OTHER TIPS

I prefer to keep main Gruntfile in js, and tasks in ls.

Example setup:

require("LiveScript")
module.exports = function(grunt){
  require('load-grunt-tasks')(grunt) // autoload npmtasks from package.json
  require('load-grunt-config')(grunt) // lets you keep each task in separate file
}

Actually, I use my own fork of load-grunt-config located on https://github.com/wolfflow/load-grunt-config/tree/beta/0.8.0

if you'd like to try it, simply add following string to your package.json file:

"load-grunt-config": "git://github.com/wolfflow/load-grunt-config.git#beta/0.8.0"

and then run npm install.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top