2
我正在關注這個SO回答How to include scripts automatically in a yeoman/grunt project?如何通過usemin插件包含腳本文件夾中的所有js文件。在我添加了grunt-include-source插件後,usemin無法用正確的concated +縮小腳本替換生成的腳本塊,只會刪除該塊或僅填充源標籤。Grunt-include-source + usemin不能一起工作
在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 -->
繁重-包括源和咕嚕-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-source之後和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 -->
有誰對這個問題的任何解決方案?
由於提前, 米哈爾
我找到了解決此問題的解決方法。我拒絕使用grunt-include-source插件並將其替換爲[grunt-file-blocks](https://github.com/rrharvey/grunt-file-blocks/)。這與grunt-usemin完美配合。 – 2014-09-15 06:45:08