-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
136 lines (122 loc) · 3.8 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* Needed gulp config */
var gulp = require('gulp');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var notify = require('gulp-notify');
var minifycss = require('gulp-minify-css');
var concat = require('gulp-concat');
var plumber = require('gulp-plumber');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('gulp-autoprefixer');
/* Setup scss path */
var paths = {
scss: './sass/*.scss'
};
/* Scripts task */
gulp.task('scripts', function() {
return gulp.src([
/* Add your JS files here, they will be combined in this order */
'js/vendor/jquery.min.js',
'js/vendor/jquery.easing.1.3.js',
'js/vendor/jquery.stellar.min.js',
'js/vendor/jquery.flexslider-min.js',
'js/vendor/jquery.countTo.js',
'js/vendor/jquery.appear.min.js',
'js/vendor/jquery.magnific-popup.min.js',
'js/vendor/owl.carousel.min.js',
'js/vendor/bootstrap.min.js',
'js/vendor/jquery.waypoints.min.js'
])
.pipe(concat('scripts.js'))
.pipe(gulp.dest('js'))
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('js'));
});
gulp.task('minify-main', function() {
return gulp.src([
/* Add your JS files here, they will be combined in this order */
'js/main.js'
])
.pipe(rename({suffix: '.min'}))
.pipe(uglify())
.pipe(gulp.dest('js'));
});
/* Sass task */
gulp.task('sass', function () {
gulp.src('scss/style.scss')
.pipe(plumber())
.pipe(sass({
errLogToConsole: true,
//outputStyle: 'compressed',
// outputStyle: 'compact',
// outputStyle: 'nested',
outputStyle: 'expanded',
precision: 10
}))
.pipe(sourcemaps.init())
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest('css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('css'))
/* Reload the browser CSS after every change */
.pipe(reload({stream:true}));
});
gulp.task('merge-styles', function () {
return gulp.src([
'css/vendor/bootstrap.min.css',
'css/vendor/animate.css',
'css/vendor/icomoon.css',
'css/vendor/flexslider.css',
'css/vendor/owl.carousel.min.css',
'css/vendor/owl.theme.default.min.css',
'css/vendor/magnific-popup.css',
'css/vendor/photoswipe.css',
'css/vendor/default-skin.css',
'fonts/icomoon/style.css',
])
// .pipe(sourcemaps.init())
// .pipe(autoprefixer({
// browsers: ['last 2 versions'],
// cascade: false
// }))
.pipe(concat('styles-merged.css'))
.pipe(gulp.dest('css'))
// .pipe(rename({suffix: '.min'}))
// .pipe(minifycss())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('css'))
.pipe(reload({stream:true}));
});
/* Reload task */
gulp.task('bs-reload', function () {
browserSync.reload();
});
/* Prepare Browser-sync for localhost */
gulp.task('browser-sync', function() {
browserSync.init(['css/*.css', 'js/*.js'], {
proxy: 'localhost/probootstrap/green'
/* For a static server you would use this: */
/*
server: {
baseDir: './'
}
*/
});
});
/* Watch scss, js and html files, doing different things with each. */
gulp.task('default', ['sass', 'scripts', 'browser-sync'], function () {
/* Watch scss, run the sass task on change. */
gulp.watch(['scss/*.scss', 'scss/**/*.scss'], ['sass'])
/* Watch app.js file, run the scripts task on change. */
gulp.watch(['js/main.js'], ['minify-main'])
/* Watch .html files, run the bs-reload task on change. */
gulp.watch(['*.html'], ['bs-reload']);
});