admin管理员组文章数量:1313153
How do people handle mon configuration options in Grunt for multiple projects. The projects would share some mon configuration options, e.g. for min
, but also have private or custom configuration settings per project, e.g. only one out of three projects requires less
or has different options for it.
Is there a way to share this mon configuration between the projects, using inheritance or importing an existing file, or does each project have to define all settings?
The projects I'm referring to would reside in a directory hierarchy like
root
module1
grunt.js
module2
grunt.js
module3
grunt.js
Is there some way to provide mon configuration settings at the root
level?
How do people handle mon configuration options in Grunt for multiple projects. The projects would share some mon configuration options, e.g. for min
, but also have private or custom configuration settings per project, e.g. only one out of three projects requires less
or has different options for it.
Is there a way to share this mon configuration between the projects, using inheritance or importing an existing file, or does each project have to define all settings?
The projects I'm referring to would reside in a directory hierarchy like
root
module1
grunt.js
module2
grunt.js
module3
grunt.js
Is there some way to provide mon configuration settings at the root
level?
1 Answer
Reset to default 10You can easily store configuration in as many external JSON files as you need. grunt.file.readJSON will help you here. For example:
module.exports = function(grunt) {
var concatConf = grunt.file.readJSON('../concat-mon.json'),
minConf = grunt.file.readJSON('../min-mon.json');
// do whatever you want with concatConf and minConf here
// ...
// Project configuration.
grunt.initConfig({
pkg: '<json:grunt-sample.jquery.json>',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
concat: concatConf,
min: minConf
// ...
});
// Default task.
grunt.registerTask('default', 'concat min');
};
Don't forget that a gruntfile is a regular JavaScript file executed in Node environment and configuration options are regular JavaScript objects :)
本文标签: javascriptInheritance for common configuration options in gruntjs configurationStack Overflow
版权声明:本文标题:javascript - Inheritance for common configuration options in grunt.js configuration - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741930883a2405566.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论