咕噜咕噜包含源 + usemin 不一起工作



我遵循这个SO答案如何在yeoman/grunt项目中自动包含脚本?如何通过usemin插件包含脚本文件夹中的所有js文件。在我添加了grunt include源代码插件后,usemin无法用正确的concated+minimized脚本替换生成的脚本块,该块只被删除或只填充了源标记。

index.html中的来源如下:

<!-- build:js(.) scripts/vendor.js -->
<!-- bower:js -->
<!-- endbower -->
<!-- endbuild -->
<!-- build:js({.tmp,app}) scripts/scripts.js -->
<!-- include: "type": "js", "files": "scripts/**/*.js" -->
<!-- endbuild -->

在grunt包含source和grunt wiredep之后的代码如下:

<!-- build:js(.) scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/json3/lib/json3.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/about.js"></script>
<script src="scripts/controllers/company/list.js"></script>
<script src="scripts/controllers/dashboard/main.js"></script>
... more ...
<!-- endbuild -->

我使用的是grunt-wiredep插件,它在grunt-include源代码之后运行,在grunt-usemin之前,此代码被正确替换。

输出应为:

<script src="scripts/vendor.1e81ad0a.js"></script>
<script src="scripts/scripts.1e82ad0a.js"></script>

但只有:

<script src="scripts/vendor.1e81ad0a.js"></script>
<!-- build:js({.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/about.js"></script>
<script src="scripts/controllers/company/list.js"></script>
<script src="scripts/controllers/dashboard/main.js"></script>
... more ...
<!-- endbuild -->

有人能解决这个问题吗?

提前感谢,Michal

在任务中:'copy:dist'注释html的副本,这样好的index.html(includesource运行后)就不会再次被应用程序中的index.html覆盖

copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,png,txt}',
            '.htaccess',
            //'*.html',
            'views/{,*/}*.html',
            'images/{,*/}*.{webp}',
            'fonts/*'
          ]
        }

相关内容

  • 没有找到相关文章

最新更新