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