ng-boilerplate grunt脚本编译

时间:2013-11-27 02:39:05

标签: angularjs gruntjs ngboilerplate

我希望能够在我自己的应用程序中复制ng-boilerplate的脚本编译过程,但我无法使其正常工作。

我指的是将index.html中的这一行编译成我应用中所有脚本的列表:

<!-- compiled JavaScript --><% scripts.forEach( function ( file ) { %>
<script type="text/javascript" src="<%= file %>"></script><% }); %>

我添加了filterForJS函数并在我的gruntfile.js中注册了多任务,但它无法正常工作:(

1 个答案:

答案 0 :(得分:2)

您是否添加了索引任务的选项?

```

/**
 * The `index` task compiles the `index.html` file as a Grunt template. CSS
 * and JS files co-exist here but they get split apart later.
 */
index: {

  /**
   * During development, we don't want to have wait for compilation,
   * concatenation, minification, etc. So to avoid these steps, we simply
   * add all script files directly to the `<head>` of `index.html`. The
   * `src` property contains the list of included files.
   */
  build: {
    dir: '<%= build_dir %>',
    src: [
      '<%= vendor_files.js %>',
      '<%= build_dir %>/src/**/*.js',
      '<%= html2js.common.dest %>',
      '<%= html2js.app.dest %>',
      '<%= vendor_files.css %>',
      '<%= recess.build.dest %>'
    ]
  },

  /**
   * When it is time to have a completely compiled application, we can
   * alter the above to include only a single JavaScript and a single CSS
   * file. Now we're back!
   */
  compile: {
    dir: '<%= compile_dir %>',
    src: [
      '<%= concat.compile_js.dest %>',
      '<%= vendor_files.css %>',
      '<%= recess.compile.dest %>'
    ]
  }
},

```