2019-10-26 11:05:04 +10:00
|
|
|
const { src, dest, series } = require('gulp');
|
2018-01-07 04:55:48 +10:00
|
|
|
const gulp = require('gulp');
|
|
|
|
const cleanCSS = require('gulp-clean-css');
|
|
|
|
const minify = require('gulp-minify');
|
|
|
|
const rename = require('gulp-rename');
|
|
|
|
|
2019-10-26 11:05:04 +10:00
|
|
|
function compressJS(){
|
|
|
|
return src(['public/javascripts/*.js', '!public/javascripts/*.min.js'])
|
2018-01-07 04:55:48 +10:00
|
|
|
.pipe(minify({
|
|
|
|
ext: {
|
|
|
|
src: '.js',
|
|
|
|
min: '.min.js'
|
|
|
|
}
|
|
|
|
}))
|
2019-10-26 11:05:04 +10:00
|
|
|
.pipe(dest('public/javascripts'));
|
|
|
|
};
|
2018-01-07 04:55:48 +10:00
|
|
|
|
2019-10-26 11:05:04 +10:00
|
|
|
function compressCss(){
|
|
|
|
return src(['public/stylesheets/*.css',
|
2018-02-14 07:15:14 +10:00
|
|
|
'!public/stylesheets/*.min.css'
|
2018-01-07 04:55:48 +10:00
|
|
|
])
|
2019-07-12 18:06:34 +10:00
|
|
|
.pipe(cleanCSS({ compatibility: 'ie8' }))
|
2018-01-07 04:55:48 +10:00
|
|
|
.pipe(rename({
|
|
|
|
dirname: 'public/stylesheets',
|
|
|
|
extname: '.min.css'
|
|
|
|
}))
|
2019-10-26 11:05:04 +10:00
|
|
|
.pipe(dest('./'));
|
|
|
|
};
|
2018-01-07 04:55:48 +10:00
|
|
|
|
2019-10-26 11:05:04 +10:00
|
|
|
function compressThemeCss(){
|
|
|
|
return src(['views/themes/**/*.css',
|
2018-02-14 07:15:14 +10:00
|
|
|
'!views/themes/**/*.min.css'
|
|
|
|
])
|
2019-07-12 18:06:34 +10:00
|
|
|
.pipe(cleanCSS({ compatibility: 'ie8' }))
|
2018-02-14 07:15:14 +10:00
|
|
|
.pipe(rename({
|
|
|
|
extname: '.min.css'
|
|
|
|
}))
|
2019-10-26 11:05:04 +10:00
|
|
|
.pipe(dest('views/themes/'));
|
|
|
|
};
|
2018-02-14 07:15:14 +10:00
|
|
|
|
2018-01-07 04:55:48 +10:00
|
|
|
// run the tasks
|
2019-10-26 11:05:04 +10:00
|
|
|
gulp.task('default', series(compressJS, compressCss, compressThemeCss));
|