我Gruntfile.js
为两个环境定义了我的任务部分 -development
和production
. 但我不明白,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 知道当前处于活动状态的是哪个环境?