前端工具bower wiredep
2015-07-23 01:26
330 查看
Bower是一个客户端技术的软件包管理器,它可用于搜索、安装和卸载如JavaScript、HTML、CSS之类的网络资源。
详细信息请参考bower官网。
几个例子:
1.当前项目需要引入jquery
只需上面简单一条命令就可以将jquery库已经其依赖的库下载下来。直接就可以在项目中引用相关的文件就可以了。
2.使用bower.json
将bower.json文件放入项目的根目录中,在项目根目录中运行
bower解决了前端库及其依赖安装的问题。至于怎么把真正所需要的文件引入到html文件中,就需要wiredep来帮忙啦。
详情参考wiredep项目主页
html文件(index.html)
gulp.js
在命令行运行
bower解决了前端库依赖管理的痛点,而wiredep解决了bower前端库引入进html的问题。
详细信息请参考bower官网。
几个例子:
1.当前项目需要引入jquery
bower install jquery
只需上面简单一条命令就可以将jquery库已经其依赖的库下载下来。直接就可以在项目中引用相关的文件就可以了。
2.使用bower.json
{ "name": "bower demo", "version": "2.9.0", "homepage": "", "authors": [ "xiaopeng <lost1q84@gmail.com>" ], "description": "bower.json test project", "keywords": [ "test" ], "license": "MIT", "ignore": [ "node_modules", "bower_components", "test", "tests" ], "dependencies": { "jquery": "~2.1.0", "angular": "~1.3.15", "angular-animate": "~1.3.15", "angular-ui-router": "~0.2.12", "ui-router-extras": "~0.0.13", "angular-bootstrap": "~0.13.0", "ngInfiniteScroll": "~1.2.0" } }
将bower.json文件放入项目的根目录中,在项目根目录中运行
bower install就可以直接将项目所需要的前端库,直接下载下来。
bower解决了前端库及其依赖安装的问题。至于怎么把真正所需要的文件引入到html文件中,就需要wiredep来帮忙啦。
详情参考wiredep项目主页
html文件(index.html)
<html> <head> <!-- bower:css --> <!-- endbower --> </head> <body> <!-- bower:js --> <!-- endbower --> </body> </html>
gulp.js
var wiredep = require('wiredep').stream; gulp.task('bower', function () { gulp.src('./index.html') .pipe(wiredep({ optional: 'configuration', goes: 'here' })) .pipe(gulp.dest('./')); });
在命令行运行
gulp bower就可以将所需库的js、css文件直接引入到html文件中。
bower解决了前端库依赖管理的痛点,而wiredep解决了bower前端库引入进html的问题。
相关文章推荐
- CSS 多浏览器兼容性问题及解决方案
- jquery - 选择器 - 试题
- JS和JQuery中的事件委托 学习笔记
- CSS+DIV简单布局
- Html菜单的实现
- css position
- javascriptde
- 代码分析jQuery四种静态方法使用
- 使用jquery实现仿百度自动补全特效
- JavaScript实现获得所有兄弟节点的方法
- js正则表达式中exec用法实例
- javascript实现框架高度随内容改变的方法
- jquery实现简单实用的打分程序实例
- jquery实现简单的轮换出现效果实例
- javascript比较两个日期相差天数的方法
- javascript实现全角半角检测的方法
- js实现汉字排序的方法
- javascript的dom模型
- html部分位置属性
- JavaScript跨域