如何在Asset Pipeline Manifest中注释掉资源

时间:2014-09-27 12:39:59

标签: css ruby-on-rails grails asset-pipeline

我需要评论application.js资产pipeleine清单文件中包含的其中一个文件,向清单添加或包含文件的方式是通过清单文件中的注释。例如 require bootstrap 表示bootstrap.css或bootstrap.js文件分别包含在应用程序的css或javascript资源中。文件的一个例子是下面的

/*
 * This is a manifest file that'll be compiled into application.css, which will include      all the files
 * listed below.
 *
 * Any CSS file within this directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require main
 *= require mobile
 *= require_self
 */
  console.log("This javascript is also added");

我想注释掉main.css,而不是删除它,在线搜索但没有找到任何有用的信息,资产管道刚刚引入到ruby on rails中的grails 2.4中,我认为能够有用在资产管道清单文件中注释掉css或javascript资源。

1 个答案:

答案 0 :(得分:8)

此CSS清单中的注释与典型的CSS注释没有什么不同。 ///* ... */。你在这里遇到的问题非常简单,你要忽略你要注释掉的行上的等号。此等号表示解析器应该对该行进行操作,删除等号会将该特定行转换为注释。

所以,要评论main

/*
 * This is a manifest file that'll be compiled into application.css, which will include      all the files
 * listed below.
 *
 * Any CSS file within this directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 * NOTICE: the line below does NOT begin with an equals sign, and will be treated as a comment.
 * require main
 *= require mobile
 *= require_self
 */
  console.log("This javascript is also added");