gpt4 book ai didi

gruntjs - 如何为 Grunt 设置环境?

转载 作者:行者123 更新时间:2023-12-03 19:58:12 25 4
gpt4 key购买 nike

我定义了我的 Gruntfile.js 的任务部分适用于两种环境 -- developmentproduction .但我不明白,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 知道当前哪个环境处于事件状态?

最佳答案

要替代,我建议您创建一个 development任务并使用 grunt development 运行它

// Default task(s).
grunt.registerTask('default', ['less:production', 'watch']);

// Development task
grunt.registerTask('development', ['less:development', 'watch']);

关于gruntjs - 如何为 Grunt 设置环境?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29391452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com