blessing-skin-server/gulpfile.js

150 lines
4.7 KiB
JavaScript
Raw Normal View History

2016-07-21 22:01:57 +08:00
/*
2017-01-18 23:05:32 +08:00
* @Author: printempw
2016-07-21 22:01:57 +08:00
* @Date: 2016-07-21 13:38:26
2016-07-22 08:54:50 +08:00
* @Last Modified by: printempw
2017-01-18 23:05:32 +08:00
* @Last Modified time: 2017-01-18 23:04:20
2016-07-21 22:01:57 +08:00
*/
2017-01-18 23:05:32 +08:00
'use strict';
let 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
2017-01-18 23:05:32 +08:00
let version = require('./package.json').version;
2016-07-21 22:01:57 +08:00
2017-01-18 23:05:32 +08:00
let vendor_js = [
2016-09-25 09:00:40 +08:00
'jquery/dist/jquery.min.js',
'bootstrap/dist/js/bootstrap.min.js',
'AdminLTE/dist/js/app.min.js',
'bootstrap-fileinput/js/fileinput.min.js',
'AdminLTE/plugins/datatables/jquery.dataTables.min.js',
'AdminLTE/plugins/datatables/dataTables.bootstrap.min.js',
2016-09-25 09:00:40 +08:00
'iCheck/icheck.min.js',
'toastr/toastr.min.js',
'sweetalert2/dist/sweetalert2.min.js',
'es6-promise/es6-promise.min.js'
2016-08-28 11:49:22 +08:00
];
2017-01-18 23:05:32 +08:00
let vendor_css = [
2016-09-25 09:00:40 +08:00
'bootstrap/dist/css/bootstrap.min.css',
'AdminLTE/dist/css/AdminLTE.min.css',
'AdminLTE/plugins/datatables/dataTables.bootstrap.css',
2016-09-25 09:00:40 +08:00
'bootstrap-fileinput/css/fileinput.min.css',
'font-awesome/css/font-awesome.min.css',
'iCheck/skins/square/blue.css',
'toastr/toastr.min.css',
'sweetalert2/dist/sweetalert2.min.css'
2016-08-28 11:49:22 +08:00
];
2017-01-18 23:05:32 +08:00
let replacements = [
2016-08-28 11:49:22 +08:00
['@import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic);', ''],
2016-09-24 23:48:52 +08:00
['../fonts/glyphicons', '../fonts/glyphicons'],
['../fonts/fontawesome', '../fonts/fontawesome'],
['blue.png', '"../images/blue.png"'],
['blue@2x.png', '"../images/blue@2x.png"'],
['../img/loading.gif', '"../images/loading.gif"'],
['../img/loading-sm.gif', '"../images/loading-sm.gif"']
2016-08-28 11:49:22 +08:00
];
2016-09-25 09:00:40 +08:00
elixir.config.sourcemaps = false;
2017-01-18 23:05:32 +08:00
elixir((mix) => {
2016-08-28 11:49:22 +08:00
mix
2017-01-18 23:05:32 +08:00
.scripts(vendor_js.map((js) => 'resources/assets/src/bower_components/' + js).concat([
2016-09-25 00:03:07 +08:00
'resources/assets/src/js/utils.js'
]), 'resources/assets/dist/js/app.min.js', './')
2016-08-28 11:49:22 +08:00
2017-01-18 23:05:32 +08:00
.styles(vendor_css.map((css) => 'resources/assets/src/bower_components/' + css), 'resources/assets/dist/css/app.min.css', './')
2016-09-25 00:03:07 +08:00
.replace('resources/assets/dist/css/app.min.css', replacements)
2016-08-28 11:49:22 +08:00
2016-08-28 18:34:41 +08:00
// copy fonts & images
2016-08-28 11:49:22 +08:00
.copy([
2016-09-25 00:03:07 +08:00
'resources/assets/src/bower_components/bootstrap/dist/fonts/**',
'resources/assets/src/bower_components/font-awesome/fonts/**'
], 'resources/assets/dist/fonts/')
2016-08-28 11:49:22 +08:00
.copy([
2016-09-25 00:03:07 +08:00
'resources/assets/src/bower_components/iCheck/skins/square/blue.png',
'resources/assets/src/bower_components/iCheck/skins/square/blue@2x.png',
'resources/assets/src/bower_components/bootstrap-fileinput/img/loading.gif',
'resources/assets/src/bower_components/bootstrap-fileinput/img/loading-sm.gif'
], 'resources/assets/dist/images/')
2016-08-28 11:49:22 +08:00
.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
2017-01-18 23:05:32 +08:00
gulp.task('sass', () => {
2016-09-25 00:03:07 +08:00
gulp.src('resources/assets/src/sass/*.scss')
2016-08-28 11:49:22 +08:00
.pipe(sass().on('error', sass.logError))
2016-07-21 22:01:57 +08:00
.pipe(cleanCss())
2016-09-25 00:03:07 +08:00
.pipe(gulp.dest('./resources/assets/dist/css'));
2016-07-21 22:01:57 +08:00
});
2017-01-18 23:05:32 +08:00
gulp.task('uglify', () => {
2016-09-25 00:03:07 +08:00
gulp.src('resources/assets/src/js/*.js')
2016-07-21 22:01:57 +08:00
.pipe(uglify())
2016-09-25 00:03:07 +08:00
.pipe(gulp.dest('./resources/assets/dist/js'));
2016-07-21 22:01:57 +08:00
});
2016-12-30 16:18:13 +08:00
function clearCache() {
return del([
2016-08-28 18:34:41 +08:00
'storage/logs/*',
2016-12-10 20:21:17 +08:00
'storage/debugbar/*',
'storage/update_cache/*',
2016-09-15 11:10:13 +08:00
'storage/yaml-translation/*',
2016-08-28 18:34:41 +08:00
'storage/framework/cache/*',
'storage/framework/sessions/*',
'storage/framework/views/*'
]);
2016-12-30 16:18:13 +08:00
}
// delete cache files
2017-01-18 23:05:32 +08:00
gulp.task('clear', () => {
2016-12-30 16:18:13 +08:00
clearCache();
});
// release
2017-01-18 23:05:32 +08:00
gulp.task('zip', () => {
2016-12-30 16:18:13 +08:00
clearCache();
2016-08-28 18:34:41 +08:00
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/**/*.*',
2016-09-15 11:10:13 +08:00
'!storage/textures/**/*.*',
2016-07-23 16:24:44 +08:00
'!.env',
'!.bowerrc',
'!.gitignore',
'!.git/**/*.*',
'!.git/',
'!.gitattributes',
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-09-25 00:03:07 +08:00
'!resources/assets/src/**/*.*',
2016-07-23 16:24:44 +08:00
'!.sass-cache/**/*.*',
2016-08-28 18:34:41 +08:00
'!.sass-cache/',
// do not pack vendor for developments
'!vendor/fzaninotto/**/*.*',
'!vendor/mockery/**/*.*',
'!vendor/phpunit/**/*.*',
'!vendor/symfony/css-selector/**/*.*',
'!vendor/symfony/dom-crawler/**/*.*'
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
});