我想用lifecript写我的Gruntfile.js
。
我已完成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.
#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
时运作)
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']);
};
答案 0 :(得分:2)
将此用作Gruntfile.js
:
require('LiveScript');
module.exports = function (grunt) {
require('./Gruntfile.ls')(grunt);
}
需要来自npm的LiveScript
包。
答案 1 :(得分:0)
我更喜欢将主Gruntfile保存在js中,而将任务保存在ls。
中示例设置:
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
}
实际上,我使用位于https://github.com/wolfflow/load-grunt-config/tree/beta/0.8.0
的load-grunt-config
分叉
如果您想尝试一下,只需将以下字符串添加到您的package.json文件中:
"load-grunt-config": "git://github.com/wolfflow/load-grunt-config.git#beta/0.8.0"
然后运行npm install
。