-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
129 lines (111 loc) · 2.33 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
const gulp = require('gulp');
const runSequence = require('run-sequence');
const svgSprite = require("gulp-svg-sprite");
const stylus = require('gulp-stylus');
const _stylus = require('stylus');
const stylobuild = require('stylobuild');
const pug = require('gulp-pug');
const rsync = require('gulp-rsync');
const sync = require('browser-sync').create();
const assets = [
'src/**',
'!src/svg{,/**}',
'!src/_icons{,/**}',
'!src/styles{,/**}',
'!src/scripts{,/**}',
'!src/fonts{,/**}',
'!src/pug{,/**}',
'!src/**/*.pug',
'!src/**/*.md',
'!src/**/*.js',
'!src/**/*.styl',
'!src/**/*~'
];
gulp.task('html', () => {
return gulp.src('src/**/index.pug')
.pipe(pug({
}))
.pipe(gulp.dest('dest'))
.pipe(sync.stream());
});
gulp.task('styles', () => {
return gulp.src('src/*.styl')
.pipe(stylus({
'include css': true,
use: stylobuild({}),
define: {
url: _stylus.resolver()
}
}))
.pipe(gulp.dest('dest'))
.pipe(sync.stream());
});
gulp.task('svg-icons', function () {
return gulp.src('src/svg/*.svg')
.pipe(svgSprite({
mode: {
symbol: {
inline: true,
prefix: '.ui-Icon_%s .ui-Icon-Image',
dest: '',
dimensions: '%s',
sprite: 'sprite.svg',
render: {
styl: true
},
example: true
}
},
svg: {
namespaceClassnames: false
}
}))
.pipe(gulp.dest("src/_icons"))
});
gulp.task('copy', () => {
return gulp.src(assets)
.pipe(gulp.dest('dest'))
.pipe(sync.stream({ once: true }));
});
gulp.task('server', () => {
sync.init({
notify: false,
server: {
baseDir: 'dest'
}
});
});
gulp.task('watch', () => {
gulp.watch(['src/**/*.pug', 'src/**/*.md', 'src/**/*.js'], ['html']);
gulp.watch(['src/**/*.css', 'src/**/*.styl'], ['styles']);
gulp.watch('src/svg/*.svg', ['build-assets-with-icons']);
gulp.watch(assets, ['copy']);
});
gulp.task('deploy', () => {
return gulp.src('dest/**/*')
.pipe(rsync({
root: 'dest',
hostname: 'pitercss.com',
destination: '/var/www/pitercss.com/html/',
recursive: true,
clean: true,
incremental: true,
exclude: '.DS_Store'
}));
});
gulp.task('build', [
'build-assets-with-icons',
'copy'
]);
gulp.task('build-assets', [
'html',
'styles'
]);
gulp.task('build-assets-with-icons', (done) => {
runSequence('svg-icons', 'build-assets', done);
});
gulp.task('default', [
'build',
'server',
'watch'
]);