【发布时间】:2015-03-17 03:10:43
【问题描述】:
我正在尝试利用 grunt-wiredep 将任何 Bower 组件自动注入到我的 html 中。非常简单,但我不确定在运行本地主机时如何设置正确的 bower 目录路径。目前我收到以下错误:
http://localhost:9000/bower_components/jquery/dist/jquery.js Failed to load resource: the server responded with a status of 404 (Not Found)
这是我的结构
项目
应用程序(包含sass、js、html等...)
凉亭组件
节点模块
bower.json
package.json
Gruntfile.js
HTML 文件
<!-- bower:js -->
<script src="../bower_components/modernizr/modernizr.js"></script>
<script src="../bower_components/jquery/dist/jquery.js"></script>
<!-- endbower -->
咕噜文件
connect: {
server: {
options: {
port: 9000,
open: true,
livereload: 35729,
hostname: 'localhost',
base:config.app
},
livereload: {
options: {
middleware: function(connect) {
return [
connect.static(config.app),
connect().use('/bower_components', connect.static('./bower_components'))
];
}
}
}
}
},
wiredep: {
task: {
// Point to the files that should be updated when you run `grunt wiredep`
src: [
'<%= config.app %>/**/*.html', // .html support...
'<%= config.app %>/views/**/*.html', // .html support...
'<%= config.app %>/views/**/*.jade', // .jade support...
'<%= config.app %>/styles/app.scss', // .scss & .sass support...
'<%= config.app %>/config.yml' // and .yml & .yaml support out of the box!
],
options: {
// See wiredep's configuration documentation for the options https://github.com/taptapship/wiredep#configuration
}
}
}
【问题讨论】:
-
嘿,您是否尝试在您的项目根目录中运行
bower install? -
@andrusieczko 是的,我有
标签: javascript html gruntjs bower grunt-wiredep