3

有人能告诉我Backbone Boilerplate(https://github.com/tbranyen/backbone-boilerplate/blob/master/index.html)的index.html中条件注释的重要性吗?

<!--(if target dummy)><!--> <link rel="stylesheet" href="/app/styles/index.css"> <!--<!(endif)-->

<!--(if target release)> <link rel="stylesheet" href="index.css"> <!(endif)-->

<!--(if target debug)> <link rel="stylesheet" href="index.css"> <!(endif)-->

<!--(if target dummy)><!-->    <script data-main="/app/config" src="/vendor/js/libs/require.js"></script>    <!--<!(endif)-->

<!--(if target release)>    <script src="require.js"></script>    <!(endif)-->

<!--(if target debug)>    <script src="require.js"></script>    <!(endif)-->

在构建不同版本时,它们是否与 Grunt 相关?

谢谢..

4

1 回答 1

5

看起来您假设这些是 Grunt 构建目标是正确的。使用 grunt 构建时,它必须具有不同的设置,例如 debug、dummy 和 release。

https://github.com/changer/grunt-targethtml

我通过搜索找到的链接示例。它也有条件评论以及一些信息。然后它在 gruntfile.js 中:

// Configuration to be run (and then tested).
targethtml: {
  dev: {
    files: {
      'tmp/dev.html': 'test/fixtures/index.html'
    }
  },
  dist: {
    files: {
      'tmp/dist.html': 'test/fixtures/index.html'
    }
  }
},...

它使用 dev 和 dist 作为条件。

Backbone Boilerplate 定义了调试和发布(虚拟似乎被排除在外):

https://github.com/tbranyen/backbone-boilerplate/blob/master/grunt.js#L131

于 2013-01-17T21:25:00.783 回答