-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·118 lines (105 loc) · 3.14 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
/* jshint node: true */
"use strict";
process.env.DISABLE_NOTIFIER = true;
//noinspection SpellCheckingInspection
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
sass = require('gulp-sass'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
order = require("gulp-order"),
livereload = require('gulp-livereload'),
notify = require('gulp-notify'),
connect = require('gulp-connect'),
cleanCSS = require('gulp-clean-css');
//vendor css
gulp.task('vendor-css', function () {
gulp.src([
'node_modules/github-fork-ribbon-css/gh-fork-ribbon.css',
'node_modules/font-awesome/css/font-awesome.css'
])
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(autoprefixer({
browsers: ['last 7 versions'],
cascade: false
}))
.pipe(cleanCSS())
.pipe(concat('vendor.css'))
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest('dist/css/'))
.pipe(connect.reload());
});
//vendor-js
gulp.task('vendor-js', function () {
gulp.src(['node_modules/jquery/dist/jquery.slim.js'])
.pipe(plumber())
.pipe(concat('vendor.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js/'))
.pipe(connect.reload());
});
//vendor assets, like fonts and images
gulp.task('vendor-assets', function () {
gulp.src(['node_modules/font-awesome/fonts/*.*'])
.pipe(gulp.dest('dist/fonts/'))
.pipe(connect.reload());
});
//sass
gulp.task('sass', function () {
gulp.src('src/scss/*.scss')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}))
.pipe(autoprefixer({
browsers: ['last 7 versions'],
cascade: false
}))
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest('dist/css/'))
.pipe(connect.reload());
});
//js
gulp.task('js', function () {
gulp.src('src/js/*.js')
.pipe(plumber())
.pipe(concat('all.js'))
.pipe(uglify())
.pipe(gulp.dest('dist/js/'))
.pipe(connect.reload());
});
// html
gulp.task('html', function () {
gulp.src('src/**/*.html')
.pipe(gulp.dest('dist/'))
.pipe(connect.reload());
});
//assets, like fonts and images
gulp.task('assets', function () {
gulp.src('src/img/*.*')
.pipe(gulp.dest('dist/img/'))
.pipe(connect.reload());
gulp.src('src/fonts/*.*')
.pipe(gulp.dest('dist/fonts/'))
.pipe(connect.reload());
});
//connect
gulp.task('connect', function () {
connect.server({
root: 'dist/',
port: 8000,
livereload: true
});
});
//Watch
gulp.task('watch', function () {
gulp.watch(['src/scss/*.scss'], ['sass']);
gulp.watch(['src/js/*.js'], ['js']);
gulp.watch(['src/img/*.*', 'src/fonts/*.*'], ['assets']);
gulp.watch(['src/**/*.html'], ['html']);
});
gulp.task('compile', ['vendor-css', 'vendor-js', 'vendor-assets', 'sass', 'js', 'assets', 'html']);
//Default Task
gulp.task('default', ['vendor-css', 'vendor-js', 'vendor-assets', 'connect', 'sass', 'js', 'assets', 'html', 'watch']);