<%= yeoman.app%>和<%= yeoman.dist%> gruntfile的变量 [英] <%= yeoman.app %> and <%=yeoman.dist %> variables for a gruntfile

查看:225
本文介绍了<%= yeoman.app%>和<%= yeoman.dist%> gruntfile的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常在一些示例gruntfiles中看到使用<%= yeoman.app%>和<%= yeoman.dist%>环境变量。我没有用过这个,但是这些变量是从哪里得到的?



另外,是否可以重写这些变量?是否需要有yeoman才能使用这些特定的环境变量?



我已阅读文档常见问题。是否有资源讨论这更多?

解决方案

这些变量从哪里派生?



从广义上讲,阅读 Gruntfile示例,因为它开始解决<%=变量%> 语法。如果您是Grunt的新手,那么将该页面添加为书签,因为那里的内容似乎并不重要,但在重复阅读时会很有用。

更具体地说,是的......那些来自Yeoman发电机。例如,如果我运行最新的 generator-angular ,它生成的Gruntfile.js包含以下代码:

  yeoman:{
//可配置路径
app:require('./ bower.json')。 appPath || 'app',
dist:'dist'
}

所以你可以至少从我使用的生成器中看到,<%= yeoman.app%> 会默认到一个名为'app'的目录, <%= yeoman.dist%> 将指向'dist'。如果我粘贴了为我创建的生成器的全部Gruntfile,您也会看到这些Gruntfile被构建和测试应用程序的许多任务所使用。



(并且您在 Gruntfile示例中看到),这不仅仅限于yeoman,因为它是Grunt的一部分,所以您可以使用它保持您的Gruntfile清洁和 DRY



是否可以重写这些变量?



是的。我上面引用的代码可以改变,这样 app dist 指向不同的位置。使用由yeoman生成器创建的应用程序执行此操作可能会导致更多工作,而不是值得的。 yeoman发电机的全部重点是自动化工作,所以你不必摆弄这些东西。您每次使用生成器都会生成一个样板文件。



...除非您从头开始编写自己的生成器或应用程序,并且是从生成器,然后是的,你可以将它们设置为对你的应用程序来说很重要。

是否需要为了使用这些特定的环境变量而拥有yeoman?

不,但如果您是从头开始构建应用程序,我认为没有任何理由使用名称'yeoman'。如果您使用的是yeoman生成的应用程序,我不会看到更改它的原因。


I often see in some example gruntfiles the use of <%= yeoman.app %> and <%= yeoman.dist %> environment variables. I haven't used this myself but where do those variables get derived from?

Also, is it possible to override those variables? Does one need to have yeoman in order to use those particular environment variables?

I've read through the documentation and the FAQ. Are there resources that discusses this more?

解决方案

Where do those variables get derived from?

Starting broadly, read the Gruntfile example as it starts to address the <%= variable %> syntax. If you are new to Grunt, bookmark that page as there's stuff there that doesn't seem important at first but will be useful on repeated reading.

More specifically, yeah...those are from a Yeoman generator. For example, if I run the latest generator-angular, the Gruntfile.js it produces includes this bit of code:

yeoman: {
  // configurable paths
  app: require('./bower.json').appPath || 'app',
  dist: 'dist'
}

So you can see, at least from the generator I used, that <%= yeoman.app %> will default to a directory called 'app' and <%= yeoman.dist %> will point to 'dist'. If I pasted the entire Gruntfile the generator created for me, you would also see these are used by many of the tasks that build and test the app.

As you can imagine (and you see in the Gruntfile example) this isn't restricted just to yeoman because is part of Grunt, so you can use this to keep your Gruntfile clean and DRY.

Is it possible to override those variables?

Yes. The code I referenced above could be changed so that the app and dist pointed to different locations. Doing this with an app created by a yeoman generator could cause more work than it is worth. The whole point of yeoman generators is to automate work so you don't have to fiddle with these things. You get a boilerplate setup every time you use a generator.

...unless you are writing your own generator or an app from scratch and are 'borrowing' bits from a generator and then yeah, you could set them to whatever is important for your app.

Does one need to have yeoman in order to use those particular environment variables?

No, but I don't see any reason to use the name 'yeoman' if you are building an app from scratch. If you are using a yeoman generated app, I don't see the reason to change it.

这篇关于&lt;%= yeoman.app%&gt;和&lt;%= yeoman.dist%&gt; gruntfile的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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