-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
107 lines (94 loc) · 2.83 KB
/
Copy pathgulpfile.js
File metadata and controls
107 lines (94 loc) · 2.83 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
var gulp = require('gulp');
var g = require('gulp-load-plugins')();
var runSequence = require('run-sequence'),
browserSync = require('browser-sync'),
clean = require('del');
gulp.task('serve', function() {
browserSync({
server: {
baseDir: './public'
},
online: false,
notify: false
});
});
gulp.task('reload', function () {
browserSync.reload();
});
gulp.task('jade', function(){
return gulp.src(['src/jade/index.pug'])
.pipe(g.data(function(){
return require('./src/jade/strings/fr.json');
}))
.pipe(g.pug({pretty:true}))
.pipe(gulp.dest('public/'))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('inter', function(){
return gulp.src(['src/jade/index.pug'])
.pipe(g.data(function(){
return require('./src/jade/strings/en.json');
}))
.pipe(g.pug({pretty:true}))
.pipe(gulp.dest('public/en/'))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('styles', function(){
return gulp.src(['src/less/main.less'])
.pipe(g.plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(g.less())
.pipe(g.autoprefixer('last 2 versions'))
.pipe(g.rename({suffix: '.min'}))
.pipe(g.cssnano())
.pipe(gulp.dest('public/assets/css/'))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('scripts', function(){
return gulp.src([
'node_modules/jquery/dist/jquery.js',
'node_modules/unveil2/dist/jquery.unveil2.min.js',
'src/scripts/main.js'
])
.pipe(g.plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(g.concat('main.js'))
.pipe(g.rename({suffix: '.min'}))
.pipe(g.uglify())
.pipe(gulp.dest('public/assets/js/'))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('images', function(){
return gulp.src('src/images/**/*')
.pipe(g.imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
optimizationLevel: 4,
multipass: true,
interlaced: true
}))
.pipe(gulp.dest('public/assets/images'));
});
gulp.task('copy', function(){
return gulp.src('src/fonts/*')
.pipe(gulp.dest('public/assets/fonts'))
.pipe(browserSync.reload({stream:true}));
});
gulp.task('clean', function() {
return clean(['public/**/*', '!public']);
});
gulp.task('build', gulp.parallel('styles', 'scripts', 'copy', 'images', 'jade', 'inter'));
gulp.task('watch', function(){
gulp.watch('src/less/**/*.less', gulp.series('styles'));
gulp.watch('src/scripts/**/*.js', gulp.series('scripts'));
gulp.watch('src/images/**/*', gulp.series('images'));
gulp.watch('src/jade/**/*.pug', gulp.series('jade', 'inter'));
gulp.watch('src/jade/strings/**/*.json', gulp.series('jade', 'inter'));
});
gulp.task('default', gulp.series('build', gulp.parallel('watch', 'serve')));