-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
153 lines (131 loc) · 3.38 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// Load plugins
var browserSync = require('browser-sync'),
gulp = require('gulp'),
autoprefixer = require("gulp-autoprefixer"),
changed = require('gulp-changed');
concat = require("gulp-concat"),
csso = require("gulp-csso"),
duration = require("gulp-duration"),
ghpages = require("gulp-gh-pages"),
less = require('gulp-less'),
notify = require("gulp-notify"),
plumber = require('gulp-plumber'),
uglify = require('gulp-uglify'),
reload = browserSync.reload,
svgsprite = require("gulp-svg-sprite");
// Path Variables
var paths = {
"html": {
"src": "src/index.html",
"dest": "dist/"
},
"icons": {
"src": "src/icons/**/*",
"dest": "dist/icons/"
},
"media": {
"src": "src/media/**",
"dest": "dist/media/"
},
"styles": {
"src": "src/less/**/*.less",
"dest": "dist/css/"
},
"js": {
"src": "src/js/*.js",
"dest": "dist/js/"
}
};
// Styles
gulp.task('styles', function() {
return gulp.src(["src/less/app.less"])
.pipe(less({ compress: true }))
.pipe(autoprefixer({ browsers: ['last 2 versions','ie 10'], cascade: false }))
.pipe(gulp.dest(paths.styles.dest))
.pipe(duration("building styles"))
//.pipe(notify({ message: "styles task complete" }))
.pipe(reload({stream:true}));
});
// Javascript
gulp.task('js', function() {
return gulp.src([
'node_modules/jquery/dist/jquery.min.js',
paths.js.src
])
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest(paths.js.dest))
.pipe(duration("building js"))
//.pipe(notify({ message: "js task complete" }))
.pipe(reload({stream:true}));
});
// HTML
gulp.task('html', function() {
return gulp.src([paths.html.src])
.pipe(reload({stream:true}))
.pipe(gulp.dest(paths.html.dest));
});
// Icons
gulp.task('icons', function() {
return gulp.src([paths.icons.src])
.pipe(svgsprite({
shape: {
id: {
generator: 'icon-',
},
dimension: {
attributes: false,
},
},
mode: {
symbol: {
dest: '',
example: false,
sprite: 'sprite.svg',
},
},
svg: {
xmlDeclaration: false,
doctypeDeclaration: false,
dimensionAttributes: false,
rootAttributes: {
style: 'border: 0; clip: rect(0 0 0 0); height: 0; overflow: hidden; padding: 0; position: absolute; width: 0;',
},
},
}))
.pipe(gulp.dest(paths.icons.dest))
.pipe(duration('Built Icons'))
.pipe(reload({ stream: true }));
});
// Images
gulp.task('media', function() {
return gulp.src([paths.media.src])
.pipe(changed(paths.media.dest))
.pipe(gulp.dest(paths.media.dest))
.pipe(reload({stream:true}));
});
// Watch
gulp.task("watch", function() {
gulp.watch(paths.styles.src, ["styles"]);
gulp.watch(paths.js.src, ["js"]);
gulp.watch(paths.html.src, ["html"]);
});
// Browser Sync
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: 'dist/'
}
});
});
// Website
gulp.task('website', function () {
return gulp.src('./dist/**/*')
.pipe(ghpages());
});
// Gulp Default
gulp.task('default', ['styles','js','media','icons']);
// Gulp Server
gulp.task('server', ['default', 'watch', 'browser-sync'], function () {
gulp.watch([paths.html.src], reload);
});