var gulp = require('gulp');
var concat = require('gulp-concat');
var runSequence = require('gulp-sequence');
var webpack = require('webpack');
var pngquant = require('pngquant');
var del = require('del');
var mergeStream=require('merge-stream');
var exec=require('child_process').exec;
var imagemin = require('gulp-imagemin');
var htmlmin = require('gulp-htmlmin');
var minicss = require('gulp-clean-css');
var uglify = require('gulp-uglify');
var pump = require('pump');
var rename = require('gulp-rename');
var jsdoc = require('gulp-jsdoc3');
var jasmineBrowser = require('gulp-jasmine-browser');
var watch = require('gulp-watch');
gulp.task('doc', function (cb) {
var config = require('./jsdoc-config.json');
gulp.src(['./app/**/*.js'], {read: false})
.pipe(jsdoc(config, cb));
});
gulp.task('imgzip', function (callback) {
pump(
[
gulp.src(['app/**/*.png', 'app/**/*.jpeg', 'app/**/*.gif']),
imagemin(
{
optimizationLevel: 5,
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}
),
gulp.dest('dist')
],
callback
);
});
gulp.task('htmlzip', function (callback) {
pump(
[
gulp.src('app/**/*.html'),
htmlmin({
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeEmptyAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
minifyJS: true,
minifyCSS: true
}),
gulp.dest('dist')
],
callback
);
});
gulp.task('csszip', function (callback) {
pump(
[
gulp.src(['app/**/*.css']),
minicss(),
gulp.dest('dist')
],
callback
);
});
gulp.task('jszip', function (callback) {
pump(
[
gulp.src('app/**/*.js'),
uglify(),
gulp.dest('dist')
],
callback
);
});
gulp.task('clear', function () {
return del(['dist']);
});
gulp.task('font', function () {
gulp.src(['app/**/*.ttf', 'app/**/*.otf', 'app/**/*.jar', 'app/**/*.xml'])
.pipe(gulp.dest('dist'))
});
gulp.task('default',
runSequence('clear',['parsezip', 'imgzip', 'htmlzip', 'csszip', 'jszip', 'font','doc'],'copy'
)
);
gulp.task('copyto', function () {
gulp.src('app/**/*')
.pipe(gulp.dest('../assets/release/Plugins/32000'))
});
gulp.task('copy', function () {
gulp.src('dist/**/*')
.pipe(gulp.dest('../assets/release/Plugins/32000'))
});
gulp.task('jasmine', function () {
var files = ['./test/src/**/*.js', './test/spec/**/*.js', 'app/js/**/*.js'];
return gulp.src(files)
.pipe(watch(files))
.pipe(jasmineBrowser.specRunner())
.pipe(jasmineBrowser.server({port: 9199}))
});
gulp.task('parsezip', function (callback) {
pump(
[
gulp.src(['app/js/json/state-inner.js',
'app/js/json/state-outdoor.js',
'app/js/json/state-basic.js',
'app/js/json/hex-unit.js',
'app/js/json/hex-parse-inner.js',
'app/js/json/hex-parse-outdoor.js',
'app/js/json/hex-parse-basic.js',
'app/js/json/json-parse-frame.js',
'app/js/json/json-send-frame.js']),
concat('parsedata.min.js'),
gulp.dest('app/js/json')
],
callback
);
});