-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
65 lines (54 loc) · 1.56 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
'use-strict';
let gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
del = require('del');
browserSync = require('browser-sync').create();
reload = browserSync.reload;
neat = require('node-neat');
gulp.task('concatScripts',['clean'], ()=> {
return gulp.src('js/app/main.js')
.pipe(sourcemaps.init())
.pipe(concat('app.js'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('js'))
});
gulp.task('minifyScripts', ['concatScripts'], ()=>{
return gulp.src('js/app.js')
.pipe(uglify())
.pipe(rename('app.min.js'))
.pipe(gulp.dest('js'))
});
gulp.task('sass', ()=>{
return gulp.src('scss/app.scss')
.pipe(sourcemaps.init())
.pipe(sass({
includePaths: require('node-neat').includePaths
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('css'))
.pipe(reload({stream: true}));
});
gulp.task('watchFiles', ()=>{
browserSync.init({
server: "./"
});
gulp.watch('scss/**/*.scss', ['sass']);
gulp.watch('js/**/*.js', ['concatScripts']);
gulp.watch('**.html').on('change', reload);
});
gulp.task('clean', ()=>{
del(['dist', 'css/app.css*', 'js/app*.js*']);
})
gulp.task('build',['minifyScripts', 'sass'], ()=>{
return gulp.src(["css/application.css", "js/app.min.js", 'index.html',
"img/**", "fonts/**"], { base: './'})
.pipe(gulp.dest('dist'));
});
gulp.task('serve', ['watchFiles']);
gulp.task('default', ['clean'], ()=>{
gulp.start('build');
});