完善打包
This commit is contained in:
parent
2009bd318d
commit
be4f189b21
46
gulpfile.js
46
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){
|
||||
|
@ -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": [
|
||||
|
Loading…
Reference in New Issue
Block a user