-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
74 lines (63 loc) · 1.97 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
var gulp = require('gulp');
var path = require('path');
var less = require('gulp-less');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var minifyCSS = require('gulp-minify-css');
var lessPluginAutoPrefix = require('less-plugin-autoprefix');
var autoprefix= new lessPluginAutoPrefix({ browsers: ["last 2 versions"] });
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
// Watching paths
var paths = {
scripts: ['src/js/**/*.js'],
images: ['staticfiles/img/**/*'],
less: ['src/less/**/*.less'],
dist: 'vespapp/staticfiles/'
};
gulp.task('default', ['less', 'fonts', 'scripts', 'images']);
gulp.task('develop', ['default', 'watch']);
gulp.task('scripts', function() {
// scripts task
return gulp.src([
'bower_components/jquery/dist/jquery.min.js',
'bower_components/bootstrap/dist/js/bootstrap.min.js',
'bower_components/sweetalert/dist/sweetalert.min.js',
'src/**/*.js'
])
.pipe(sourcemaps.init())
.pipe(concat('main.min.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(path.join(paths.dist, 'js/')));
});
gulp.task('fonts', function() {
gulp.src('./bower_components/font-awesome/fonts/**/*.{ttf,woff,woff2,eof,svg}')
.pipe(gulp.dest('./vespapp/staticfiles/css/fonts'));
});
gulp.task('watch', function() {
// main task
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.less, ['less']);
});
gulp.task('less', function() {
// main task
return gulp.src('./src/less/main.less')
.pipe(less({
plugins: [autoprefix]
}))
.pipe(minifyCSS())
.pipe(concat('main.min.css'))
.pipe(gulp.dest('./vespapp/staticfiles/css'));
});
gulp.task('images', function() {
return gulp.src('src/img/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [
{removeViewBox: false},
{cleanupIDs: false}
],
use: [pngquant()]
}))
.pipe(gulp.dest('./vespapp/staticfiles/img'));
});