0

jgraph-3.8.0

使用gulp压缩

相关代码

//导入工具包
var gulp = require('gulp'); //本地安装gulp所用到的地方
//var less = require('gulp-less');
var cssmin = require('gulp-minify-css'); //压缩css
//var autoprefixer = require('gulp-autoprefixer'); //自动添加浏览器前缀
var uglify = require('gulp-uglify'); //压缩js文件
var concat = require('gulp-concat'); //合并所有js文件
//var watch = require('gulp-watch');
var rename = require('gulp-rename');
//当发生异常时提示错误 确保本地安装gulp-notify和gulp-plumber
const notify = require('gulp-notify');
const plumber = require('gulp-plumber');
const gutil = require('gulp-util');
// 映射
const sourcemaps = require('gulp-sourcemaps');
gulp.task('util', function() {
return gulp.src(['./util/*.js'])

    // .pipe(sourcemaps.init())
    .pipe(concat('util.js'))
    .pipe(uglify())
    // .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./util'))

});
gulp.task('shape', function() {
return gulp.src(['./shape/*.js'])

    // .pipe(sourcemaps.init())
    .pipe(concat('shape.js'))
    .pipe(uglify())
    // .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./shape'))

});
gulp.task('layout', function() {
return gulp.src(['./layout/*.js'])

    // .pipe(sourcemaps.init())
    .pipe(concat('layout.js'))
    .pipe(uglify())
    // .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./layout'))

});
gulp.task('model', function() {
return gulp.src(['./model/*.js'])

    // .pipe(sourcemaps.init())
    .pipe(concat('model.js'))
    .pipe(uglify())
    // .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./model'))

});
gulp.task('view', function() {
return gulp.src(['./view/*.js'])

    // .pipe(sourcemaps.init())
    .pipe(concat('view.js'))
    .pipe(uglify())
    // .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./view'))

});
gulp.task('handler', function() {
return gulp.src(['./handler/*.js'])

    // .pipe(sourcemaps.init())
    .pipe(concat('handler.js'))
    .pipe(uglify())
    // .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./handler'))

});
gulp.task('editor', function() {
return gulp.src(['./editor/*.js'])

    // .pipe(sourcemaps.init())
    .pipe(concat('editor.js'))
    .pipe(uglify())
    // .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./editor'))

});
gulp.task('io', function() {
return gulp.src(['./io/*.js'])

    // .pipe(sourcemaps.init())
    .pipe(concat('io.js'))
    .pipe(uglify())
    // .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('./io'))

});
//单目录合并
gulp.task('minify', ['util','shape','layout','model','view','handler','editor','io']);

进行性能调优,把资源文件压缩成一个文件,可正常使用?

2019-01-11 提问
0 个回答

撰写答案

推广链接