2016-07-21 22:01:57 +08:00
|
|
|
/*
|
|
|
|
* @Author: prpr
|
|
|
|
* @Date: 2016-07-21 13:38:26
|
2016-07-22 08:54:50 +08:00
|
|
|
* @Last Modified by: printempw
|
2016-08-14 13:38:46 +08:00
|
|
|
* @Last Modified time: 2016-08-14 13:33:51
|
2016-07-21 22:01:57 +08:00
|
|
|
*/
|
|
|
|
|
2016-07-22 08:54:50 +08:00
|
|
|
var gulp = require('gulp'),
|
|
|
|
jshint = require('gulp-jshint'),
|
|
|
|
concat = require('gulp-concat'),
|
|
|
|
uglify = require('gulp-uglify'),
|
|
|
|
sass = require('gulp-ruby-sass'),
|
|
|
|
cleanCss = require('gulp-clean-css'),
|
|
|
|
rename = require('gulp-rename'),
|
|
|
|
del = require('del'),
|
2016-07-23 16:24:44 +08:00
|
|
|
replace = require('gulp-replace')
|
|
|
|
zip = require('gulp-zip');
|
|
|
|
|
2016-08-06 22:14:00 +08:00
|
|
|
var version = require('./package.json').version;
|
2016-07-21 22:01:57 +08:00
|
|
|
|
|
|
|
/**
|
2016-07-22 08:54:50 +08:00
|
|
|
* Copy files from bower_components to dist for later operations
|
2016-07-21 22:01:57 +08:00
|
|
|
*/
|
2016-07-22 08:54:50 +08:00
|
|
|
gulp.task('copy', function(cb) {
|
2016-07-21 22:01:57 +08:00
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/jquery/dist/jquery.min.js')
|
|
|
|
.pipe(gulp.dest('./assets/libs/js/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/bootstrap/dist/css/bootstrap.min.css')
|
|
|
|
.pipe(gulp.dest('./assets/libs/css/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/bootstrap/dist/fonts/**')
|
|
|
|
.pipe(gulp.dest('./assets/fonts/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/bootstrap/dist/js/bootstrap.min.js')
|
|
|
|
.pipe(gulp.dest('./assets/libs/js/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/AdminLTE/dist/css/AdminLTE.min.css')
|
|
|
|
.pipe(replace('@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic);', ''))
|
|
|
|
.pipe(gulp.dest('./assets/libs/css/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/AdminLTE/dist/css/skins/**')
|
|
|
|
.pipe(gulp.dest('./assets/libs/skins/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/AdminLTE/dist/js/app.min.js')
|
|
|
|
.pipe(gulp.dest('./assets/libs/js/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/bootstrap-fileinput/css/fileinput.min.css')
|
|
|
|
.pipe(gulp.dest('./assets/libs/css/'));
|
|
|
|
|
|
|
|
gulp.src(['./assets/bower_components/bootstrap-fileinput/js/fileinput.min.js',
|
|
|
|
'./assets/bower_components/bootstrap-fileinput/js/locales/zh.js'])
|
|
|
|
.pipe(concat('fileinput.min.js'))
|
|
|
|
.pipe(gulp.dest('./assets/libs/js/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/font-awesome/css/font-awesome.min.css')
|
|
|
|
.pipe(gulp.dest('./assets/libs/css/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/font-awesome/fonts/**')
|
|
|
|
.pipe(gulp.dest('./assets/fonts/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/iCheck/skins/square/blue.css')
|
2016-07-22 08:54:50 +08:00
|
|
|
.pipe(replace('blue.png', '"../images/blue.png"'))
|
|
|
|
.pipe(replace('blue@2x.png', '"../images/blue@2x.png"'))
|
2016-07-21 22:01:57 +08:00
|
|
|
.pipe(gulp.dest('./assets/libs/css/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/iCheck/skins/square/blue.png')
|
|
|
|
.pipe(gulp.dest('./assets/images/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/iCheck/skins/square/blue@2x.png')
|
|
|
|
.pipe(gulp.dest('./assets/images/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/iCheck/icheck.min.js')
|
|
|
|
.pipe(gulp.dest('./assets/libs/js/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/toastr/toastr.min.css')
|
|
|
|
.pipe(gulp.dest('./assets/libs/css/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/toastr/toastr.min.js')
|
|
|
|
.pipe(gulp.dest('./assets/libs/js/'));
|
2016-08-14 13:38:46 +08:00
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/sweetalert2/dist/sweetalert2.min.css')
|
|
|
|
.pipe(gulp.dest('./assets/libs/css/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/sweetalert2/dist/sweetalert2.min.js')
|
|
|
|
.pipe(gulp.dest('./assets/libs/js/'));
|
|
|
|
|
|
|
|
gulp.src('./assets/bower_components/es6-promise/es6-promise.min.js')
|
|
|
|
.pipe(gulp.dest('./assets/libs/js/'));
|
2016-07-21 22:01:57 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('lint', function() {
|
|
|
|
return gulp.src('./assets/js/*.js')
|
|
|
|
.pipe(jshint())
|
|
|
|
.pipe(jshint.reporter('default'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('lib-css', function() {
|
|
|
|
gulp.src([
|
|
|
|
'./assets/libs/css/bootstrap.min.css',
|
|
|
|
'./assets/libs/css/AdminLTE.min.css',
|
|
|
|
'./assets/libs/css/fileinput.min.css',
|
|
|
|
'./assets/libs/css/font-awesome.min.css',
|
|
|
|
'./assets/libs/css/blue.css',
|
2016-08-14 13:38:46 +08:00
|
|
|
'./assets/libs/css/toastr.min.css',
|
|
|
|
'./assets/libs/css/sweetalert2.min.css'
|
2016-07-21 22:01:57 +08:00
|
|
|
])
|
|
|
|
.pipe(concat('app.min.css'))
|
|
|
|
.pipe(cleanCss())
|
|
|
|
.pipe(gulp.dest('./assets/dist/'))
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('lib-scripts', function() {
|
|
|
|
gulp.src([
|
|
|
|
'./assets/libs/js/jquery.min.js',
|
|
|
|
'./assets/libs/js/bootstrap.min.js',
|
|
|
|
'./assets/libs/js/app.min.js',
|
|
|
|
'./assets/libs/js/icheck.min.js',
|
|
|
|
'./assets/libs/js/fileinput.min.js',
|
|
|
|
'./assets/libs/js/toastr.min.js',
|
2016-08-14 13:38:46 +08:00
|
|
|
'./assets/libs/js/es6-promise.min.js',
|
|
|
|
'./assets/libs/js/sweetalert2.min.js',
|
2016-07-21 22:01:57 +08:00
|
|
|
'./assets/src/js/utils.js'
|
|
|
|
])
|
|
|
|
.pipe(concat('app.min.js'))
|
|
|
|
.pipe(uglify())
|
|
|
|
.pipe(gulp.dest('./assets/dist/'))
|
|
|
|
});
|
|
|
|
|
2016-07-22 08:54:50 +08:00
|
|
|
/**
|
|
|
|
* Concat css and js files to one file
|
|
|
|
*/
|
|
|
|
gulp.task('concat', ['lib-css', 'lib-scripts']);
|
|
|
|
|
2016-07-21 22:01:57 +08:00
|
|
|
// compile sass
|
|
|
|
gulp.task('sass', function() {
|
|
|
|
return sass('./assets/src/sass/*.scss')
|
|
|
|
.on('error', function (error) {
|
|
|
|
console.error('Error!', error.message);
|
|
|
|
})
|
|
|
|
.pipe(cleanCss())
|
2016-07-22 10:48:24 +08:00
|
|
|
// .pipe(rename({'suffix': '.min'}))
|
2016-07-21 22:01:57 +08:00
|
|
|
.pipe(gulp.dest('./assets/dist/css'));
|
|
|
|
})
|
|
|
|
|
|
|
|
gulp.task('scripts', function() {
|
|
|
|
gulp.src([
|
|
|
|
'./assets/src/js/*.js',
|
|
|
|
'!./assets/src/js/utils.js'
|
|
|
|
])
|
|
|
|
.pipe(uglify())
|
2016-07-22 10:48:24 +08:00
|
|
|
// .pipe(rename({'suffix': '.min'}))
|
2016-07-21 22:01:57 +08:00
|
|
|
.pipe(gulp.dest('./assets/dist/js'));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('minify', ['sass', 'scripts']);
|
|
|
|
|
2016-08-14 13:38:46 +08:00
|
|
|
gulp.task('clean', function (cb) {
|
2016-07-21 22:01:57 +08:00
|
|
|
return del([
|
|
|
|
'./assets/libs/css/**',
|
|
|
|
'./assets/libs/js/**'
|
|
|
|
], cb);
|
|
|
|
});
|
|
|
|
|
2016-08-14 13:38:46 +08:00
|
|
|
gulp.task('build', ['concat', 'minify']);
|
2016-07-21 22:01:57 +08:00
|
|
|
|
2016-07-23 16:24:44 +08:00
|
|
|
// release
|
|
|
|
gulp.task('zip', function() {
|
|
|
|
del('resources/cache/*');
|
|
|
|
|
|
|
|
return gulp.src([
|
|
|
|
'**/*.*',
|
2016-07-29 16:13:21 +08:00
|
|
|
'LICENSE',
|
2016-07-24 11:13:41 +08:00
|
|
|
'!tests/**/*.*',
|
2016-07-23 16:24:44 +08:00
|
|
|
'!node_modules/**/*.*',
|
|
|
|
'!textures/**/*.*',
|
|
|
|
'!.env',
|
|
|
|
'!.bowerrc',
|
|
|
|
'!.gitignore',
|
|
|
|
'!.git/**/*.*',
|
|
|
|
'!.git/',
|
|
|
|
'!koala-config.json',
|
|
|
|
'!gulpfile.js',
|
|
|
|
'!package.json',
|
|
|
|
'!composer.json',
|
|
|
|
'!composer.lock',
|
|
|
|
'!bower.json',
|
|
|
|
'!assets/bower_components/**/*.*',
|
|
|
|
'!assets/src/**/*.*',
|
|
|
|
'!.sass-cache/**/*.*',
|
|
|
|
'!.sass-cache/'
|
|
|
|
], { dot: true })
|
2016-08-06 22:15:15 +08:00
|
|
|
.pipe(zip('blessing-skin-server-v'+version+'.zip'))
|
2016-07-23 16:24:44 +08:00
|
|
|
.pipe(gulp.dest('./'));
|
|
|
|
});
|
|
|
|
|
2016-07-22 08:54:50 +08:00
|
|
|
gulp.task('default', ['copy']);
|