我正在尝试将wiredep与我的项目连接起来,但没有成功。我在 assets/ 中有 bower_components 和 bower.json,在根目录中有 gruntfile.js。这是相关的 gruntfile:
wiredep: {
target: {
src: [
'grunt-test.html',
'application/views/inc/inc_scripts.php',
'application/views/inc/inc_head.php'
],
directory: 'assets/bower_components',
bowerJson: 'assets/bower.json',
fileTypes: {
php: {
block: /(([\s\t]*)<!--\s*bower:*(\S*)\s*-->)(\n|\r|.)*?(<!--\s*endbower\s*-->)/gi,
detect: {
js: /<script.*src=['"](.+)['"]>/gi,
css: /<link.*href=['"](.+)['"]/gi
},
replace: {
js: '<script src="{{filePath}}"></script>', // <-- Change this line
css: '<link rel="stylesheet" href="{{filePath}}" />'
}
},
html: {
block: /(([\s\t]*)<!--\s*bower:*(\S*)\s*-->)(\n|\r|.)*?(<!--\s*endbower\s*-->)/gi,
detect: {
js: /<script.*src=['"](.+)['"]>/gi,
css: /<link.*href=['"](.+)['"]/gi
},
replace: {
js: '<script src="{{filePath}}"></script>', // <-- Change this line
css: '<link rel="stylesheet" href="{{filePath}}" />'
}
}
}
}
}
然后我运行grunt wiredep --verbose
并得到以下输出:
Running "wiredep" task
Running "wiredep:target" (wiredep) task
Verifying property wiredep.target exists in config...OK
Files: grunt-test.html, application/views/inc/inc_scripts.php, application/views
/inc/inc_head.php
Verifying property wiredep.target.src exists in config...OK
Options: src=["grunt-test.html","application/views/inc/inc_scripts.php","application/views/inc/inc_head.php"], directory="assets/bower_components", bowerJson="a ssets/bower.json",fileTypes={"php":{"block":{},"detect":{"js":{},"css":{}},"replace":{"js":"<script src=\"{{filePath}}\"></script>","css":"<link rel=\"stylesheet\" href=\"{{filePath}}\" />"}},"html":{"block":{},"detect":{"js":{},"css":{}},"replace":{"js":"<script src=\"{{filePath}}\"></script>","css":"<link rel=\"stylesheet\" href=\"{{filePath}}\" />"}}}
Done, without errors.
但什么也没有发生。我已经确定我使用了正确的标签,甚至尝试添加一个 HTML 文件 (grunt-test.html) 以确保它不是文件类型的东西,但我现在不知所措。
你们看到了什么?
提前致谢。