Febu
前端构建工具
安装
- 命令行窗口需要能执行
git
命令 - 编辑
config/default.js
并另存为config/local.js
(可选步骤) - 安装依赖
npm install -g gulp
npm install
发布
仅支持发布git项目
参数
- repo git仓库地址
- branch 分支,默认是
master
- commit 版本号,默认是
HEAD
- publicPath 静态资源前缀,默认从项目的
febu.json
里取
发布到测试环境
gulp development --repo repo [--branch branch] [--commit commitid] [--publicPath publicPath]
例如发布项目amd_demo的master
分支的最新代码
gulp development --repo https://github.com/holyzfy/trygit
发布到生产环境
gulp production --repo repo [--branch branch] [--commit commitid] [--publicPath publicPath]
约定规则
inc
inc目录存放html碎片,html碎片里的静态资源路径是相对于仓库根目录
html
html文件里script,link标签可以使用以下属性(生产环境下有效)
属性 | 描述 |
---|---|
_group | 合并多个标签的外部资源 |
_inline | 把静态资源的内容直接输出到页面 |
_compress | 与_inline配合使用,输出压缩后的内容 |
_group示例
对于同一个页面,_group值一样的link标签合并到一起,_group值一样的script标签合并到一起
原始代码
处理后
_inline和_compress示例
原始代码
处理后
febu.json
项目根目录下创建febu.json,来指定部署的配置项(所有配置项都是选填),示例:
"build": "./build.js" // requirejs的构建脚本,示例 https://github.com/holyzfy/amd_demo/blob/master/build.js "ignore": // 忽略的文件或目录 "node_modules" "build" "build.js" "test" "development": // 发布到测试环境时静态资源前缀 "publicPath": "//static.f2e.example.com/project" "production": // 发布到生产环境时静态资源前缀 "publicPath": "//examplecdn.com/project"
测试
- 安装依赖
npm install -g mocha
- 运行
npm test