Giter VIP home page Giter VIP logo

gulp-final's Introduction

玉珏念北Gulp前端自动化

Gulp代码检测 (jsHint版)

Gulp bower下载插件

Gulp 自动监测文件变化 (watch)

Gulp 代码压缩 (压缩JS、Css、Html)

Gulp 单元测试(基于mocha的单元测试)

Gulp 自动添加版本号(对文件自动添加版本)

Gulp git链接(暂无)

基于gulp-rev + gulp-rev-collector根据文件MD5值自动添加版本号,提供修改插件改变xxx-md5.xxxxx.xx?v=md5方法

Autoprefixer自动添加浏览器厂商兼容前缀

安装

npm install / cnpm install

建议使用淘宝镜像

npm bower / bower update

安装bower插件

使用

gulp / npm test  //测试环境
gulp build / npm run build  //正式发布
gulp clean  //清除缓存

配置

代码压缩

生产/测试环境下  condition = false; 不对js css html压缩
正式发布环境下  condition = true; 对js css html压缩

注意:先运行测试环境才能正式发布

文件版本管理

默认结果(xxx-md5.xx):

"/css/style.css" => "/dist/css/style-1d87bebe.css"    
"/js/script1.js" => "/dist/script1-61e0be79.js"    
"cdn/image.gif"  => "//cdn8.example.dot/img/image-35c3af8134.gif"

高级配置(xxx.xx?v=md5):

  1. 打开node_modules\gulp-rev\index.js

    第133行 manifest[originalFile] = revisionedFile;
    更新为: manifest[originalFile] = originalFile + '?v=' + file.revHash;

  2. 打开nodemodules\gulp-rev\nodemodules\rev-path\index.js

    10行 return filename + '-' + hash + ext;
    更新为: return filename + ext;

  3. 打开node_modules\gulp-rev-collector\index.js

    31行 if ( path.basename(json[key]).replace(new RegExp( opts.revSuffix ), '' ) !== path.basename(key) ) {
    更新为: if ( path.basename(json[key]).split('?')[0] !== path.basename(key) ) {

输出:

background: url('../img/one.jpg?v=28bd4f6d18');

href="css/main.css?v=885e0e1815"

src: url('/fonts/icomoon.eot?v=921bbb6f59');
src="js/main.js?v=10ba7be289"
src="img/one.jpg?v=28bd4f6d18"

gulp-final's People

Contributors

yujuenianbei avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.