blessing-skin-server/gulpfile.js

123 lines
4.0 KiB
JavaScript
Raw Normal View History

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-28 18:34:41 +08:00
* @Last Modified time: 2016-08-28 18:29:06
2016-07-21 22:01:57 +08:00
*/
2016-07-22 08:54:50 +08:00
var gulp = require('gulp'),
2016-08-28 11:49:22 +08:00
elixir = require('laravel-elixir'),
2016-07-22 08:54:50 +08:00
uglify = require('gulp-uglify'),
2016-08-28 11:49:22 +08:00
sass = require('gulp-sass'),
2016-07-22 08:54:50 +08:00
cleanCss = require('gulp-clean-css'),
2016-08-28 18:34:41 +08:00
del = require('del'),
2016-07-23 16:24:44 +08:00
zip = require('gulp-zip');
2016-08-28 11:49:22 +08:00
require('laravel-elixir-replace');
2016-08-28 10:05:21 +08:00
var version = require('./package.json').version;
2016-07-21 22:01:57 +08:00
2016-08-28 11:49:22 +08:00
var vendor_js = [
'resources/assets/bower_components/jquery/dist/jquery.min.js',
'resources/assets/bower_components/bootstrap/dist/js/bootstrap.min.js',
'resources/assets/bower_components/AdminLTE/dist/js/app.min.js',
'resources/assets/bower_components/bootstrap-fileinput/js/fileinput.min.js',
'resources/assets/bower_components/bootstrap-fileinput/js/locales/zh.js',
'resources/assets/bower_components/iCheck/icheck.min.js',
'resources/assets/bower_components/toastr/toastr.min.js',
'resources/assets/bower_components/sweetalert2/dist/sweetalert2.min.js',
'resources/assets/bower_components/es6-promise/es6-promise.min.js'
];
var vendor_css = [
'resources/assets/bower_components/bootstrap/dist/css/bootstrap.min.css',
'resources/assets/bower_components/AdminLTE/dist/css/AdminLTE.min.css',
'resources/assets/bower_components/bootstrap-fileinput/css/fileinput.min.css',
'resources/assets/bower_components/font-awesome/css/font-awesome.min.css',
'resources/assets/bower_components/iCheck/skins/square/blue.css',
'resources/assets/bower_components/toastr/toastr.min.css',
'resources/assets/bower_components/sweetalert2/dist/sweetalert2.min.css'
];
var replacements = [
['@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic);', ''],
['blue.png', '"../images/blue.png"'],
['blue@2x.png', '"../images/blue@2x.png"']
];
elixir(function(mix) {
mix
2016-08-28 18:34:41 +08:00
.scripts(vendor_js.concat([
'resources/assets/js/utils.js'
]), 'assets/js/app.min.js', './')
2016-08-28 11:49:22 +08:00
.styles(vendor_css, 'assets/css/app.min.css', './')
.replace('assets/css/app.min.css', replacements)
2016-08-28 18:34:41 +08:00
// copy fonts & images
2016-08-28 11:49:22 +08:00
.copy([
'resources/assets/bower_components/bootstrap/dist/fonts/**',
'resources/assets/bower_components/font-awesome/fonts/**'
], 'assets/fonts/')
.copy([
'resources/assets/bower_components/iCheck/skins/square/blue.png',
'resources/assets/bower_components/iCheck/skins/square/blue@2x.png'
], 'assets/images/')
.task('sass')
2016-08-28 18:34:41 +08:00
.task('uglify');
2016-07-21 22:01:57 +08:00
});
2016-08-28 11:49:22 +08:00
// compile sass
gulp.task('sass', function () {
gulp.src('resources/assets/sass/*.scss')
.pipe(sass().on('error', sass.logError))
2016-07-21 22:01:57 +08:00
.pipe(cleanCss())
2016-08-28 11:49:22 +08:00
.pipe(gulp.dest('./assets/css'));
2016-07-21 22:01:57 +08:00
});
2016-08-28 18:34:41 +08:00
gulp.task('uglify', function() {
2016-08-28 11:49:22 +08:00
gulp.src('resources/assets/js/*.js')
2016-07-21 22:01:57 +08:00
.pipe(uglify())
2016-08-28 11:49:22 +08:00
.pipe(gulp.dest('./assets/js'));
2016-07-21 22:01:57 +08:00
});
2016-07-23 16:24:44 +08:00
// release
gulp.task('zip', function() {
2016-08-28 18:34:41 +08:00
// delete cache files
del([
'storage/logs/*',
'storage/framework/cache/*',
'storage/framework/sessions/*',
'storage/framework/views/*'
]);
2016-07-23 16:24:44 +08:00
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/',
2016-08-28 18:34:41 +08:00
'!artisan',
2016-07-23 16:24:44 +08:00
'!koala-config.json',
'!gulpfile.js',
'!package.json',
'!composer.json',
'!composer.lock',
'!bower.json',
2016-08-28 18:34:41 +08:00
'!resources/assets/**/*.*',
2016-07-23 16:24:44 +08:00
'!.sass-cache/**/*.*',
2016-08-28 18:34:41 +08:00
'!.sass-cache/',
'!storage/logs/*.*',
// do not pack vendor since laravel contains huge dependencies
'!vendor/**/*.*'
2016-07-23 16:24:44 +08:00
], { dot: true })
2016-08-06 22:15:15 +08:00
.pipe(zip('blessing-skin-server-v'+version+'.zip'))
2016-08-20 21:59:09 +08:00
.pipe(gulp.dest('../'));
2016-07-23 16:24:44 +08:00
});