【发布时间】:2015-06-06 03:20:13
【问题描述】:
我为development 和production 两个环境定义了Gruntfile.js 的任务部分。但我不明白,Grunt 是如何决定的,是否使用哪个环境部分。
Gruntfile.js
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
development: {
options: {
paths: ["public/css"]
},
files: {
"public/css/style.css": "public/css/style.less"
}
},
production: {
options: {
paths: ["public/css"],
plugins: [
],
modifyVars: {
}
},
files: {
"public/css/style.css": "public/css/style.less"
}
}
},
watch: {
css: {
files: 'public/css/*.less',
tasks: ['less'],
options: {
livereload: true,
},
},
}
});
// Load the plugin that provides the "less" task.
grunt.loadNpmTasks('grunt-contrib-less');
// Load the plugin that provides the "watch" task.
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task(s).
grunt.registerTask('default', ['less', 'watch']);
};
如何让 Grunt 知道当前处于活动状态的环境?
【问题讨论】:
标签: gruntjs config development-environment production-environment gruntfile