1

我想Gruntfile.js用livescript写我的。

我已经完成了Gruntfile.js,并且Gruntfile.coffee两者都可以开箱即用

Gruntfile.ls应该工作......对吗?

我在网上看过一些Gruntfile.ls,还是需要编译(.coffee 版本除外)?

现场脚本

(调用时出错$ 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.

咕噜文件.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]>

编译:

(打电话时有效$ 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']);
};
4

2 回答 2

2

将此用作您的Gruntfile.js

require('LiveScript');

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

需要LiveScript来自 npm 的包。

于 2014-04-03T22:50:32.783 回答
0

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.

于 2014-04-10T08:02:40.100 回答