grunt.config


本文整理自网络,侵删。

grunt.config

从 Gruntfile 中获取针对当前项目的配置数据。

注意,任何标记为 ? (unicode snowman) 的方法也是可以直接通过 grunt 对象访问的;任何标记为 ☆ (white star) 的方法都可以在task内部通过 this 对象访问的。请知晓。

初始化配置数据

注意,下面列出的方法也可以通过 grunt 对象访问,访问形式为 grunt.initConfig

grunt.config.init

为当前项目初始化一个配置对象。其中传入的 configObject 参数可以用在后续的task中,可以通过grunt.config 方法访问。几乎每个项目的 Gruntfile 都会调用此方法。

grunt.config.init(configObject)

注意,任何 <% %> 模板字符串只会在取到配置数据后才被处理。

下面的案例展示了针对 grunt-contrib-jshint插件 中的 jshint task的配置数据:

grunt.config.init({
  jshint: {
    all: ['lib/*.js', 'test/*.js', 'Gruntfile.js']
  }
});

查看 Getting started 指南可以获取更多的配置案例。

此方法还可以以 grunt.initConfig 的形式访问。

获取配置数据

The following methods allow Grunt configuration data to be accessed either via dot-delimited string like'pkg.author.name' or via array of property name parts like ['pkg', 'author', 'name'].

阅读剩余部分

相关阅读 >>

Grunt 配置任务

Grunt.config

Grunt 创建插件

Grunt.log

Grunt.option

Grunt 深入任务内幕

Gruntfile 实例

Grunt.file

Grunt 常见问题

Grunt 退出码

更多相关阅读请进入《Grunt》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...