-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
92 lines (75 loc) · 2.3 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
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var concat = require('gulp-concat');
var autoprefixer = require('gulp-autoprefixer');
var sourcemaps = require('gulp-sourcemaps');
var merge = require ('merge-stream');
var cssnano = require ('gulp-cssnano');
var sass = require('gulp-sass');
sass.compiler = require('node-sass');
// Static server
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "app/"
}
});
});
// sass
gulp.task('sass', function() {
return gulp.src('app/sass/main.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer(['last 2 versions'], { cascade: true }))
.pipe(gulp.dest('app/css/'))
.pipe(browserSync.reload({stream: true}))
});
// sass lib
gulp.task('sass-lib', function() {
return gulp.src('app/sass/lib/*')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer(['last 2 versions'], { cascade: true }))
.pipe(gulp.dest('app/css/lib/'))
.pipe(browserSync.reload({stream: true}))
});
// concat js
gulp.task('scripts', function() {
return gulp.src([
'app/js/libs/jquery-3.3.1.min.js',
'app/js/libs/slick.min.js'
])
.pipe(concat('all.js'))
.pipe(gulp.dest('app/js/'));
});
//min
gulp.task('css-min', function() {
return gulp.src('app/css/all.css')
.pipe(cssnano())
.pipe(gulp.dest('app/css/'))
});
//build
gulp.task('build', function() {
var buildCss = gulp.src([
'app/css/reset.css',
'app/css/main.css',
'app/css/all.css'
])
.pipe(gulp.dest('dist/css'));
var buildFonts = gulp.src('app/fonts/**/*')
.pipe(gulp.dest('dist/fonts'));
var buildImg = gulp.src('app/img/**/*')
.pipe(gulp.dest('dist/img'));
var buildJs = gulp.src([
'app/js/all.js',
'app/js/common.js'
])
.pipe(gulp.dest('dist/js'));
var buildHtml = gulp.src('app/*.html')
.pipe(gulp.dest('dist'));
});
// gulp watch
gulp.task('watch', ['browser-sync', 'scripts', 'sass', 'sass-lib'], function() {
gulp.watch('app/*.html', browserSync.reload);
gulp.watch('app/js/**/*.js', browserSync.reload);
gulp.watch('app/sass/**/*.scss', ['sass'], browserSync.reload);
});
gulp.task('default', ['watch']);