-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
55 lines (45 loc) · 1.36 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
'use strict';
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
maps = require('gulp-sourcemaps'),
del = require('del');
gulp.task("concatScripts", function(){
return gulp.src([
'js/one.js',
'js/two.js'])
.pipe(maps.init())
.pipe(concat('app.js'))
.pipe(maps.write('./'))
.pipe(gulp.dest('js'));
});
gulp.task("minifyScripts", ['concatScripts'], function(){
return gulp.src("js/app.js")
.pipe(uglify())
.pipe(rename('app.min.js'))
.pipe(gulp.dest('js'));
});
gulp.task("compileSass", function(){
return gulp.src("css/main.scss")
.pipe(maps.init())
.pipe(sass({ outputStyle: 'compressed' }))
.pipe(maps.write('./'))
.pipe(gulp.dest('css'));
});
gulp.task('watchFiles', function(){
gulp.watch('css/**/*.scss', ['compileSass']);
gulp.watch('js/two.js', ['concatScripts']);
});
gulp.task('clean', function(){
del(['dist', 'css/main.css', 'css/main.css.map','js/app.js', 'js/app*.js*']);
});
gulp.task("build", ['minifyScripts', 'compileSass'], function(){
return gulp.src(['css/main.css', 'js/app.js', 'index.html', "img/**"], { base: './'})
.pipe(gulp.dest('dist'));
});
gulp.task('serve', ['watchFiles']);
gulp.task("default", ["clean"], function(){
gulp.start('build'); //this will change in gulp 4
});