-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·78 lines (69 loc) · 2.08 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*global require*/
// Load Plugins
const sass = require('gulp-sass')(require('sass'));
var gulp = require('gulp'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
cleanCSS = require('gulp-clean-css'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat');
// Styles
gulp.task('styles', function () {
return gulp.src('scss/theme.scss')
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sass().on('error', sass.logError))
.pipe(rename({suffix: '.min'}))
.pipe(cleanCSS())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
});
// Styles ecommerce
gulp.task('styles-ecommerce', function () {
return gulp.src('scss/custom/ecommerce/theme.scss')
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sass().on('error', sass.logError))
.pipe(rename({basename: 'ecommerce', suffix: '.min'}))
.pipe(cleanCSS())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
});
// Scripts
gulp.task('scripts', function () {
return gulp.src([
'js/bootstrap/*.js',
'js/vendor/*.js',
'js/custom/*.js',
'js/theme.js'
])
.pipe(sourcemaps.init())
.pipe(concat('theme.js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
});
// Images
gulp.task('images', function () {
import('gulp-imagemin').then((imagemin) => {
gulp.src('images/*')
.pipe(imagemin.default({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(gulp.dest('dist/images'));
});
});
// Fonts
gulp.task('fonts', function () {
return gulp.src('fonts/**/*')
.pipe(gulp.dest('dist/fonts'));
});
// Default task
gulp.task('default',
gulp.parallel('styles', 'styles-ecommerce', 'scripts', 'fonts')
);
// Watch
gulp.task('watch', function () {
// Watch .scss files
gulp.watch(['scss/**/*.scss'], gulp.parallel('styles', 'styles-ecommerce'));
// gulp.watch(['scss/**/*.scss'], ['styles'])
// Watch .js files
gulp.watch('js/**/*.js', gulp.parallel('scripts'));
});