从咕噜声模板访问流程/环境 [英] Accessing the process / environment from a grunt template

查看:112
本文介绍了从咕噜声模板访问流程/环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在grunt.js文件中有一些代码与0.3一起工作,但在0.4中断:

  {
dest:'<%= process.env.DEST%> /index.html'
}

在0.3过程中进行了定义,因此我可以访问模板内部环境中定义的变量将文件路径传递给其他插件。



有没有其他方法可以在0.4下工作?或者在模板呈现时放置断点,以便我可以看到哪些变量可用? href =http://gruntjs.com/api/grunt.config>默认数据是配置对象。您可以将环境变量添加到配置对象中,或直接使用它。

  grunt.initConfig({
destination :process.env.DEST,
任务:{
target:{
dest:'<%= destination%> /index.html'
}
},
});

  grunt.initConfig({
任务:{
目标:{
dest:process.env.DEST +'/index.html'
}
},
});


I have some code in a grunt.js file which is working with 0.3 but breaks on 0.4:

{
    dest: '<%= process.env.DEST %>/index.html'
}

In 0.3 process is defined and so I can access variables defined in the environment inside the template when I am e.g. passing file paths to other plugins.

Is there an alternative approach to this which will work in 0.4? Or a way to put a breakpoint in while the template is rendering so that I can see what variables are available?

解决方案

The default data is the config object. You can add the environment variable to the config object or just use it directly.

grunt.initConfig({
    destination: process.env.DEST,
    task: {
        target: {
            dest: '<%= destination %>/index.html'
        }
    },
});

or

grunt.initConfig({
    task: {
        target: {
            dest: process.env.DEST + '/index.html'
        }
    },
});

这篇关于从咕噜声模板访问流程/环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆