ng-boilerplate grunt scripts compilation

假如想象 提交于 2019-12-11 12:07:09

问题


I would like to be able to duplicate ng-boilerplate's script compilation process in my own app, but I am unable to get it working.

I am referring to having this line in index.html be compiled into a list of all the scripts in my app:

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

I added the filterForJS function and registered the multi task in my gruntfile.js, but it is not working :(


回答1:


Have you added the options for the index task?

```

/**
 * 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 %>'
    ]
  }
},

```



来源:https://stackoverflow.com/questions/20232899/ng-boilerplate-grunt-scripts-compilation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!