From be4f189b218545694728879f4a900b2c4c270591 Mon Sep 17 00:00:00 2001 From: sentsin Date: Thu, 24 Aug 2017 20:26:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gulpfile.js | 46 +++++++++++++++++++++++++++++++++++++++------- package.json | 6 ++++-- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 6a7061bf..da8691fc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,6 +13,7 @@ var header = require('gulp-header'); var del = require('del'); var gulpif = require('gulp-if'); var minimist = require('minimist'); +var zip = require('gulp-zip'); //获取参数 var argv = require('minimist')(process.argv.slice(2), { @@ -30,6 +31,10 @@ var argv = require('minimist')(process.argv.slice(2), { //模块 ,mods = 'laytpl,laypage,laydate,jquery,layer,element,upload,form,tree,table,carousel,util,flow,layedit,code' +//发行版本目录 +,releaseDir = './release/layui-v' + pkg.version + '/layui-v' + pkg.version +,release = releaseDir + '/layui' + //任务 ,task = { @@ -48,7 +53,7 @@ var argv = require('minimist')(process.argv.slice(2), { ,'!./src/lay/all.js' ,'!./src/lay/all-mobile.js' ] - ,dir = ver ? 'release' : 'dist'; + ,dir = ver ? release : 'dist'; //过滤 layim if(ver || argv.open){ @@ -69,7 +74,7 @@ var argv = require('minimist')(process.argv.slice(2), { './src/**/{layui,all,'+ mods +'}.js' ,'!./src/**/mobile/*.js' ] - ,dir = ver ? 'release' : 'dist'; + ,dir = ver ? release : 'dist'; return gulp.src(src).pipe(uglify()) .pipe(concat('layui.all.js', {newLine: ''})) @@ -86,7 +91,7 @@ var argv = require('minimist')(process.argv.slice(2), { ,'./src/lay/modules/laytpl.js' ,'./src/**/mobile/{'+ mods +'}.js' ] - ,dir = ver ? 'release' : 'dist'; + ,dir = ver ? release : 'dist'; if(ver || argv.open){ src.push('./src/**/mobile/layim-mobile-open.js'); @@ -106,7 +111,7 @@ var argv = require('minimist')(process.argv.slice(2), { ver = ver === 'open'; var src = ['./src/css/**/*.css'] - ,dir = ver ? 'release' : 'dist' + ,dir = ver ? release : 'dist' ,noteNew = JSON.parse(JSON.stringify(note)); if(ver || argv.open){ @@ -125,7 +130,7 @@ var argv = require('minimist')(process.argv.slice(2), { ,font: function(ver){ ver = ver === 'open'; - var dir = ver ? 'release' : 'dist'; + var dir = ver ? release : 'dist'; return gulp.src('./src/font/*') .pipe(rename({})) @@ -137,7 +142,7 @@ var argv = require('minimist')(process.argv.slice(2), { ver = ver === 'open'; var src = ['./src/**/*.{png,jpg,gif,html,mp3,json}'] - ,dir = ver ? 'release' : 'dist'; + ,dir = ver ? release : 'dist'; if(ver || argv.open){ src.push('!./src/**/layim/**/*.*'); @@ -146,6 +151,12 @@ var argv = require('minimist')(process.argv.slice(2), { gulp.src(src).pipe(rename({})) .pipe(gulp.dest('./'+ dir)); } + + //复制发行的引导文件 + ,release: function(){ + gulp.src('./release/doc/**/*') + .pipe(gulp.dest(releaseDir)); + } }; //清理 @@ -153,7 +164,7 @@ gulp.task('clear', function(cb) { return del(['./dist/*'], cb); }); gulp.task('clearRelease', function(cb) { - return del(['./release/*'], cb); + return del([releaseDir], cb); }); gulp.task('minjs', task.minjs); @@ -162,6 +173,7 @@ gulp.task('mobile', task.mobile); gulp.task('mincss', task.mincss); gulp.task('font', task.font); gulp.task('mv', task.mv); +gulp.task('release', task.release); //开源版 gulp.task('default', ['clearRelease'], function(){ //命令:gulp @@ -170,6 +182,26 @@ gulp.task('default', ['clearRelease'], function(){ //命令:gulp } }); +//压缩 +gulp.task('zip', function(){ + gulp.src('./release/layui-v' + pkg.version + '/**/*') + .pipe(zip('layui-v' + pkg.version + '.zip')) + .pipe(gulp.dest('./release')); +}); + +//打包LayIM +gulp.task('layim', function(){ + var dir = './release/layui.layim-v'+ pkg.layimV; + gulp.src('./release/doc-layim/**/*') + .pipe(gulp.dest(dir)) + + gulp.src('./src/**/*') + .pipe(gulp.dest(dir + '/src')) + + return gulp.src('./dist/**/*') + .pipe(gulp.dest(dir + '/dist')) +}); + //完整任务 gulp.task('all', ['clear'], function(){ //命令:gulp all,过滤layim:gulp all --open for(var key in task){ diff --git a/package.json b/package.json index dc9523d2..11864f63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "layui", "version": "2.0.2", + "layimV": "3.7.0", "description": "经典模块化前端框架", "main": "layui.js", "license": "MIT", @@ -14,14 +15,14 @@ "author": "贤心", "homepage": "http://www.layui.com", "devDependencies": { - "del": "^2.2.2", "gulp": "^3.9.1", + "gulp-uglify": "^1.5.4", "gulp-concat": "^2.6.0 ", "gulp-header": "^1.8.8", "gulp-if": "^2.0.1", "gulp-minify-css": "^1.2.4", "gulp-rename": "^1.2.2", - "gulp-uglify": "^1.5.4", + "del": "^2.2.2", "gulp-zip": "^4.0.0", "minimist": "^1.2.0" }, @@ -41,6 +42,7 @@ "gulp-if": "^2.0.1", "gulp-rename": "^1.2.2", "del": "^2.2.2", + "gulp-zip": "^gulp-zip", "minimist": "^1.2.0" }, "keywords": [