-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
106 lines (93 loc) · 2.73 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
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
var basePaths = {
src: 'frontdev/',
dest: 'src/static/'
};
var paths = {
fonts: {
src: basePaths.src + 'font/',
dest: basePaths.dest + 'font/'
},
images: {
src: basePaths.src + 'img/',
dest: basePaths.dest + 'img/'
},
scripts: {
src: basePaths.src + 'js/',
dest: basePaths.dest + 'js/'
},
styles: {
src: basePaths.src + 'sass/',
dest: basePaths.dest + 'css/'
},
};
var appFiles = {
fonts: paths.fonts.src + '**',
images: paths.images.src + '**',
scripts: paths.scripts.src + '**',
scriptsBrowserify: paths.scripts.src + '*.js',
styles: paths.styles.src + '**/*.scss',
};
/*Let the magic begin*/
var gulp = require('gulp'),
del = require('del'),
compass = require('gulp-compass'),
path = require('path'),
gutil = require('gulp-util'),
minifyCSS = require('gulp-minify-css'),
livereload = require('gulp-livereload'),
browserify = require('gulp-browserify'),
gulpif = require('gulp-if'),
uglify = require('gulp-uglify');
imagemin = require('gulp-imagemin');
isProduction = false;
gulp.task('clean', function(cb) {
del([basePaths.dest, basePaths.src + 'css'], cb);
});
gulp.task('copy', function() {
gulp.src(paths.fonts.src + '**')
.pipe(gulp.dest(paths.fonts.dest));
gulp.src(paths.images.src + '**')
.pipe( gulpif ( isProduction, imagemin ({
progressive: true,
svgoPlugins: [{removeViewBox: false}]
}) ) )
.pipe(gulp.dest(paths.images.dest))
.pipe(livereload());
});
gulp.task('compass', function() {
gulp.src(appFiles.styles)
.pipe(compass({
sass: paths.styles.src,
css: basePaths.src + 'css',
font: paths.fonts.src,
image: paths.images.src
}))
.pipe(gulpif(isProduction, minifyCSS()))
.pipe(gulp.dest(paths.styles.dest))
.pipe(livereload());
});
gulp.task('scripts', function() {
gulp.src(appFiles.scriptsBrowserify)
.pipe(browserify({
insertGlobals: false,
debug: false
}))
.pipe(gulpif(isProduction, uglify()))
.pipe(gulp.dest(paths.scripts.dest));
});
// Rerun the task when a file changes
gulp.task('watch', function() {
livereload.listen();
gulp.watch(appFiles.images, ['copy']);
gulp.watch(appFiles.fonts, ['copy']);
gulp.watch(appFiles.styles, ['compass']);
gulp.watch(appFiles.scripts, ['scripts']);
});
gulp.task('default', ['clean'], function() {
// gulp.start('compass', 'copy', 'scripts', 'watch');
gulp.start('compass', 'copy', 'watch');
});
gulp.task('dist', ['clean'], function() {
isProduction = true;
gulp.start('compass', 'copy', 'scripts');
});