-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
180 lines (163 loc) · 4.58 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
var gulp = require('gulp'),
sass = require('gulp-sass'),
cleanCSS = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
pump = require('pump'),
pug = require('gulp-pug'),
imagemin = require('gulp-imagemin'),
realFavicon = require ('gulp-real-favicon'),
fs = require('fs'),
htmlmin = require('gulp-htmlmin');
var browserSync = require('browser-sync').create();
var path = {
SRC: './src',
BUILD: './docs',
BUILDAssets: './docs/assets'
};
var folder = {
css: '/css',
scss: '/scss/',
js: '/js/',
pug: '/pug/',
images: '/images/',
favicon: '/favicon/'
};
gulp.task('browserSync', function () {
browserSync.init({
server: {
baseDir: path.BUILD + '/'
}
})
});
/*
* Task to compile SCSS into CSS
*/
gulp.task('sass', function (callback) {
pump([
gulp.src(path.SRC + folder.scss + '**/*.scss'),
sass(),
cleanCSS(),
gulp.dest(path.BUILDAssets + folder.css),
browserSync.reload({
stream: true
})
], callback);
});
/*
* Task to uglify JAVASCRIPT
*/
gulp.task('javascript', function (callback) {
pump([
gulp.src(path.SRC + folder.js + '**/*.js'),
uglify(),
gulp.dest(path.BUILDAssets + folder.js),
browserSync.reload({
stream: true
})
], callback);
});
/*
* Task to compile PUG files to HTML
*/
gulp.task('pug', function (callback) {
pump([
gulp.src(path.SRC + folder.pug + '*.pug'),
pug({}),
realFavicon.injectFaviconMarkups(JSON.parse(fs.readFileSync(FAVICON_DATA_FILE)).favicon.html_code),
htmlmin({
collapseWhitespace: true
}),
gulp.dest(path.BUILD + '/'),
browserSync.reload({
stream: true
})
], callback);
});
/*
* Task to minimize Images and moving to docs folder
*/
gulp.task('images', function (callback) {
pump([
gulp.src(path.SRC + folder.images + '*.*'),
imagemin(),
gulp.dest(path.BUILDAssets + folder.images)
], callback)
});
/*
* Task for favicon creation
*/
var FAVICON_DATA_FILE = 'faviconData.json';
gulp.task('generate-favicon', function(done) {
realFavicon.generateFavicon({
masterPicture: path.SRC + folder.favicon + 'favicon.png',
dest: path.BUILDAssets + folder.favicon,
iconsPath: 'assets/favicon/',
design: {
ios: {
pictureAspect: 'noChange',
assets: {
ios6AndPriorIcons: false,
ios7AndLaterIcons: false,
precomposedIcons: false,
declareOnlyDefaultIcon: true
}
},
desktopBrowser: {},
windows: {
pictureAspect: 'noChange',
backgroundColor: '#da532c',
onConflict: 'override',
assets: {
windows80Ie10Tile: false,
windows10Ie11EdgeTiles: {
small: false,
medium: true,
big: false,
rectangle: false
}
}
},
androidChrome: {
pictureAspect: 'noChange',
themeColor: '#da532c',
manifest: {
name: 'Simple Budget App',
shortName: 'Budget App',
startUrl: '/',
display: 'standalone',
orientation: 'notSet',
onConflict: 'override',
declared: true
},
assets: {
legacyIcon: false,
lowResolutionIcons: false
}
},
safariPinnedTab: {
pictureAspect: 'blackAndWhite',
threshold: 40.625,
themeColor: '#da532c'
}
},
settings: {
scalingAlgorithm: 'Mitchell',
errorOnImageTooSmall: false,
readmeFile: false,
htmlCodeFile: false,
usePathAsIs: false
},
markupFile: FAVICON_DATA_FILE
}, function() {
done();
});
});
/*
* Task for watches
*/
gulp.task('watch', ['browserSync', 'sass', 'javascript', 'pug'], function () {
gulp.watch(path.SRC + folder.scss + '**/*.scss', ['sass']);
gulp.watch(path.SRC + folder.js + '**/*.js', ['javascript']);
gulp.watch(path.SRC + folder.pug + '**/*.pug', ['pug']);
});
gulp.task('default', ['watch', 'sass', 'pug', 'images']);