{"action":"created","issue":{"url":"https://api.github.com/repos/Wscats/glup/issues/2","repository_url":"https://api.github.com/repos/Wscats/glup","labels_url":"https://api.github.com/repos/Wscats/glup/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/Wscats/glup/issues/2/comments","events_url":"https://api.github.com/repos/Wscats/glup/issues/2/events","html_url":"https://github.com/Wscats/glup/issues/2","id":169574679,"number":2,"title":"gulp环境配置","user":{"login":"Wscats","id":17243165,"avatar_url":"https://avatars.githubusercontent.com/u/17243165?v=3","gravatar_id":"","url":"https://api.github.com/users/Wscats","html_url":"https://github.com/Wscats","followers_url":"https://api.github.com/users/Wscats/followers","following_url":"https://api.github.com/users/Wscats/following{/other_user}","gists_url":"https://api.github.com/users/Wscats/gists{/gist_id}","starred_url":"https://api.github.com/users/Wscats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wscats/subscriptions","organizations_url":"https://api.github.com/users/Wscats/orgs","repos_url":"https://api.github.com/users/Wscats/repos","events_url":"https://api.github.com/users/Wscats/events{/privacy}","received_events_url":"https://api.github.com/users/Wscats/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-08-05T10:06:12Z","updated_at":"2016-09-07T09:25:30Z","closed_at":null,"body":"**目录结构**\r\n![这里写图片描述](http://img.blog.csdn.net/20160805181030250)\r\n**代码如下**\r\n```\r\nvar gulp = require('gulp'),\r\n\tminifycss = require('gulp-minify-css'),\r\n\t//minifyhtml = require('gulp-minify-html'),\r\n\tconcat = require('gulp-concat'),\r\n\tuglify = require('gulp-uglify'),\r\n\t//imagemin = require('gulp-imagemin'),\r\n\trename = require('gulp-rename'),\r\n\tdel = require('del'),\r\n\tless = require('gulp-less');\r\n \r\ngulp.task('less', function () {\r\n    return gulp.src('less/bootstrap.less')\r\n        .pipe(less())\r\n        .pipe(gulp.dest('dist/style'));\r\n});\r\ngulp.task('minify', function() {\r\n\treturn gulp.src(['js/*.js'])\r\n\t\t.pipe(concat('main.js')) //合并所有js到main.js\r\n\t\t.pipe(rename({\r\n\t\t\tsuffix: '.min'\r\n\t\t})) //rename压缩后的文件名 让main.js变成main.min.js\r\n\t\t.pipe(uglify()) //执行压缩\r\n\t\t.pipe(gulp.dest('./dist/js'))\r\n});\r\ngulp.task('minifycss', function() {\r\n\treturn gulp.src('./style/*.css') //压缩的文件\r\n\t\t.pipe(concat('main.css')) //合并所有js到main.js\r\n\t\t.pipe(rename({\r\n\t\t\tsuffix: '.min'\r\n\t\t}))\r\n\t\t.pipe(minifycss())\r\n\t\t.pipe(gulp.dest('./dist/style')); //输出文件夹\r\n});\r\n\r\ngulp.task('imagemin', function() {\r\n    return gulp.src('./images/*.+(jpeg|jpg|png)')\r\n        .pipe(imagemin({\r\n            optimizationLevel: 7, //类型：Number  默认：3  取值范围：0-7（优化等级）\r\n            progressive: true, //类型：Boolean 默认：false 无损压缩jpg图片\r\n            interlaced: true, //类型：Boolean 默认：false 隔行扫描gif进行渲染\r\n            multipass: true //类型：Boolean 默认：false 多次优化svg直到完全优化\r\n        }))\r\n        .pipe(gulp.dest('./dist/images'));\r\n});\r\n\r\ngulp.task('default', ['minify', 'minifycss', 'less', 'imagemin']);\r\n```"},"comment":{"url":"https://api.github.com/repos/Wscats/glup/issues/comments/245225177","html_url":"https://github.com/Wscats/glup/issues/2#issuecomment-245225177","issue_url":"https://api.github.com/repos/Wscats/glup/issues/2","id":245225177,"user":{"login":"Wscats","id":17243165,"avatar_url":"https://avatars.githubusercontent.com/u/17243165?v=3","gravatar_id":"","url":"https://api.github.com/users/Wscats","html_url":"https://github.com/Wscats","followers_url":"https://api.github.com/users/Wscats/followers","following_url":"https://api.github.com/users/Wscats/following{/other_user}","gists_url":"https://api.github.com/users/Wscats/gists{/gist_id}","starred_url":"https://api.github.com/users/Wscats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wscats/subscriptions","organizations_url":"https://api.github.com/users/Wscats/orgs","repos_url":"https://api.github.com/users/Wscats/repos","events_url":"https://api.github.com/users/Wscats/events{/privacy}","received_events_url":"https://api.github.com/users/Wscats/received_events","type":"User","site_admin":false},"created_at":"2016-09-07T09:25:30Z","updated_at":"2016-09-07T09:25:30Z","body":"监听JS变化，有JS变化就执行压缩JS的任务\r\n`gulp.watch('./script/*.js', ['minify']);`"}}
{"actor":{"display_login":"Wscats"}}