expressCart/gulpfile.js

77 lines
1.7 KiB
JavaScript
Raw Normal View History

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');
2019-12-26 20:32:28 +10:00
const less = require('gulp-less');
2018-01-07 04:55:48 +10:00
const cleanCSS = require('gulp-clean-css');
const minify = require('gulp-minify');
const rename = require('gulp-rename');
2019-12-26 20:32:28 +10:00
function lessCss(){
return gulp.src('public/stylesheets/less/**/*.less')
2019-12-26 20:32:28 +10:00
.pipe(less({
paths: [
'public/stylesheets/less'
]
}))
.pipe(rename({
dirname: 'public/stylesheets',
extname: '.css'
}))
.pipe(gulp.dest('./'));
};
2019-10-26 11:05:04 +10:00
function compressJS(){
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(){
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(){
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-26 20:32:28 +10:00
gulp.task('default', series(lessCss, compressJS, compressCss, compressThemeCss, compressThemeJS));