我正在尝试利用 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_components
节点模块
鲍尔.json
包.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
}
}
}