简体   繁体   English

可以将Gruntfile.js文件重命名吗?

[英]Can Gruntfile.js file be renamed?

I'm using grunt now which I'm very thankful of because it is very convenient. 我现在正在使用grunt,非常感谢,因为它非常方便。 However my boss said the he wants to rename the Gruntfile.js file because it is confusing. 但是我的老板说他想重命名Gruntfile.js文件,因为它令人困惑。 He wants to rename it to Start.js. 他想将其重命名为Start.js。 So is it possible to rename it? 可以重命名吗? Is there a way to rename it? 是否可以重命名?

There isn't a good way as far as I'm aware. 据我所知,没有一个好方法。

The issue you'll have is that npm, and other package managers will overwrite it on update even if you hacked its core to work properly with a different filename. 您将遇到的问题是npm,即使您破解了内核以使用其他文件名正常工作,其他软件包管理器也会在更新时覆盖它。

You might be able to piece something together using symbolic links, and hiding the original, but that's dependent on your OS, and is really a different question. 您也许可以使用符号链接将某些内容拼凑在一起,然后隐藏原始内容,但这取决于您的OS,实际上是一个不同的问题。

Seriously, save yourself a massive headache and just tell them it can't be done. 认真地,让自己免于沉重的头痛,并告诉他们这不可能。

Actually there is a way. 其实有办法。 For future references please use this method: http://gruntjs.com/using-the-cli#gruntfile 为了将来的参考,请使用此方法: http : //gruntjs.com/using-the-cli#gruntfile

"Specify an alternate Gruntfile. By default, grunt looks in the current or parent directories for the nearest Gruntfile.js or Gruntfile.coffee file." “指定备用Gruntfile。默认情况下,grunt在当前目录或父目录中查找最近的Gruntfile.js或Gruntfile.coffee文件。”

So, I renamed my file as Start.js. 因此,我将文件重命名为Start.js。 I'll call it in the cli as grunt --gruntfile=Start.js That's it. 我在cli中将其称为grunt --gruntfile = Start.js就是这样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM