我的脚本和咕unt声有问题。我不愿意将我的脚本“复制”到dist。
因此,useminPrepare不包含或复制bower_components。
这是我的咕unt声文件:http://pastebin.com/1aFMABam
这是useminPrepare
useminPrepare: {
options: {
dest: '<%= config.dist %>'
},
html: '.tmp/index.html'
},
我得到的HTML:
<!-- build:js(.) scripts/vendor.js-->
<!-- bower:js-->
<script src="/bower_components/modernizr/modernizr.js"></script>
<script src="/bower_components/jquery/dist/jquery.js"></script>
<script src="/bower_components/bootstrap-sass/assets/javascripts/bootstrap.js"></script>
<script src="/bower_components/bootstrap-switch/dist/js/bootstrap-switch.js"></script>
<script src="/bower_components/sifter/sifter.js"></script>
<script src="/bower_components/microplugin/src/microplugin.js"></script>
<script src="/bower_components/selectize/dist/js/selectize.js"></script>
<script src="/bower_components/tinymce/tinymce.min.js"></script>
<script src="/bower_components/chai/chai.js"></script>
<script src="/bower_components/mocha/mocha.js"></script>
<!-- endbower-->
<!-- endbuild-->
<!-- build:js(.) scripts/plugins.js-->
<!-- endbuild-->
<!-- build:js scripts/main.js-->
<script src="scripts/main.js"></script>
<!-- endbuild-->
和我的脚本文件夹输出。
Script
|- Vendor
|- modernizr.js
结果我想要
我想像这样在文件夹中获取每个组件:
<script src="script/jquery/jquery.js"></script>
<script src="script/angular/angular.js"></script>
<script src="script/etc/etc.js"></script>
顺便说一句:它甚至不包括main.js!
调试任务
Loading "usemin.js" tasks...OK
+ usemin, useminPrepare
Running "useminPrepare" task
Running "useminPrepare:html" (useminPrepare) task
Verifying property useminPrepare.html exists in config...OK
Files: [no src] -> html
Options: dest="dist"
Going through to update the config
Looking for build script HTML comment blocks
Configuration is now:
concat:
{ dist: {} }
uglify:
{ dist: { files: { '<%= config.dist %>/scripts/scripts.js': [ 'dist/scripts/scripts.js' ] } } }
cssmin:
{ dist:
{ files:
{ '<%= config.dist %>/styles/main.css':
[ '.tmp/styles/{,*/}*.css',
'app/styles/{,*/}*.css' ] } } }
Done, without errors.
Execution Time (2015-09-11 06:43:02 UTC)
loading tasks 246ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 73%
loading grunt-usemin 68ms ▇▇▇▇▇▇▇▇▇ 20%
useminPrepare:html 25ms ▇▇▇ 7%
Total 339ms
最佳答案
我通过更改useminprepare的来源解决了该问题,因为src位于.tmp上,而jade:dist不在此处编译HTML,而是直接编译生成。
关于javascript - Grunt build useminprepare无法正常工作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32517161/