-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
81 lines (77 loc) · 2.08 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
// Get Gulp packages
var gulp = require('gulp');
// Packages Declaration
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var cleancss = require('gulp-clean-css');
var concat = require('gulp-concat');
var gutil = require('gulp-util');
var sourcemaps = require('gulp-sourcemaps');
var del = require('del');
var browserSync = require('browser-sync').create();
var autoprefixer = require('gulp-autoprefixer');
// Gulp Default tasks
gulp.task('default', ['check', 'clean', 'sass', 'scripts', 'browser-sync', 'watch']);
// Gulp Watch function
gulp.task('watch', function() {
gulp.watch('scss/*.scss', ['sass']);
gulp.watch('js/*.js', ['scripts']);
gulp.watch('*.html').on('change', browserSync.reload);
})
// SASS Compile + Minify
gulp.task('sass', function() {
return gulp.src(
[
'node_modules/bootstrap-grid/dist/grid.min.css',
'node_modules/font-awesome/css/font-awesome.min.css',
'scss/*.scss'
])
.pipe(sourcemaps.init())
.pipe(autoprefixer({
browsers: ['last 5 versions'],
cascade: false
}))
.pipe(sass().on('error', gutil.log))
.pipe(cleancss())
.pipe(concat('app.css'))
.pipe(rename({
suffix: ".min"
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'))
.pipe(browserSync.reload({stream: true}))
});
// Concat + Minify .js
gulp.task('scripts', function() {
return gulp.src(
[
'node_modules/jquery/dist/jquery.min.js',
'js/*.js'
])
.pipe(sourcemaps.init())
.pipe(uglify().on('error', gutil.log))
.pipe(concat('app.js'))
.pipe(rename({
suffix: ".min"
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'))
.pipe(browserSync.reload({stream: true}))
});
// Clear build folder
gulp.task('clean', function() {
return del.sync(['dist/*']);
});
// browser-sync server
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "./"
}
});
});
// Gulp run test
gulp.task('check', function() {
console.log('Tasks running..');
});