-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
150 lines (126 loc) · 3.83 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
require('dotenv').load();
var gulp = require('gulp');
var gutil = require('gutil');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var CacheBuster = require('gulp-cachebust');
var cachebust = new CacheBuster();
var include = require('gulp-include');
var minifyHTML = require('gulp-htmlmin');
var minifySVG = require('gulp-svgmin');
var decompress = require('gulp-decompress');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var ftp = require( 'vinyl-ftp' );
gulp.task('assets', function() {
return gulp.src('./favicons.zip')
.pipe( decompress() )
.pipe( gulp.dest('build/') )
});
gulp.task('default', function () {
return gulp.src('logo.svg')
.pipe(svgmin())
.pipe(gulp.dest('./out'));
});
gulp.task('css', function () {
return gulp.src('./assets/styles/*.scss')
.pipe( sass({ outputStyle: 'compressed'}).on('error', sass.logError) )
.pipe( autoprefixer('> 0.4%') )
.pipe( cachebust.resources() )
.pipe( gulp.dest('build/assets/styles/') );
});
gulp.task('css:dev', function () {
return gulp.src('./assets/styles/*.scss')
.pipe( sass().on('error', sass.logError) )
.pipe( autoprefixer('> 0.4%') )
.pipe( gulp.dest('build/assets/styles/') );
});
gulp.task('css:watch', function () {
gulp.watch('./sass/**/*.scss', ['sass']);
});
gulp.task('html', function () {
return gulp.src('index.html')
.pipe( include() )
.pipe( minifyHTML({collapseWhitespace: true}) )
.pipe( gulp.dest('build/') );
});
gulp.task('javascript:dev', function () {
var b = browserify({
entries: './assets/js/script.js',
debug: true
})
.transform("babelify", { presets: ["es2015"] });
var webfont = browserify({
entries: './assets/js/webfont.js',
debug: true
});
webfont.bundle()
.pipe( source('./assets/js/webfont.js') )
.pipe( buffer() )
.pipe( sourcemaps.init({loadMaps: true}) )
.pipe( sourcemaps.write('./') )
.pipe( gulp.dest('./build/') );
return b.bundle()
.pipe( source('./assets/js/script.js') )
.pipe( buffer() )
.pipe( sourcemaps.init({loadMaps: true}) )
.pipe( sourcemaps.write('./') )
.pipe( gulp.dest('./build/') );
});
gulp.task('javascript', function () {
var b = browserify({
entries: './assets/js/script.js'
})
.transform("babelify", { presets: ["es2015"] });
var webfont = browserify({
entries: './assets/js/webfont.js',
});
webfont.bundle()
.pipe( source('./assets/js/webfont.js') )
.pipe( buffer() )
.pipe( uglify() )
.pipe( cachebust.resources() )
.pipe( gulp.dest('./build/') );
return b.bundle()
.pipe( source('./assets/js/script.js') )
.pipe( buffer() )
.pipe( uglify() )
.pipe( cachebust.resources() )
.pipe( gulp.dest('./build/') );
});
gulp.task('watch', function() {
gulp.watch(['index.html', 'components/*.html', './assets/images/overtone-spiral.svg'], ['html']);
gulp.watch(['./assets/styles/*.scss', './assets/styles/**/*.scss'], ['css:dev']);
gulp.watch(['./assets/js/**/*.js', './assets/js/**/*.json'], ['javascript:dev']);
});
gulp.task('build', ['css', 'javascript'], function(){
return gulp.src('index.html')
.pipe( include() )
.pipe( minifyHTML({collapseWhitespace: true}) )
.pipe( cachebust.references() )
.pipe( gulp.dest('build/') );
});
gulp.task('deploy', ['build', 'clean'], function(){
var conn = ftp.create( {
host: process.env.FTP_HOST,
user: process.env.FTP_USER,
password: process.env.FTP_PASS,
parallel: 10,
log: gutil.log
} );
return gulp.src( 'build/**', { buffer: false } )
.pipe( conn.dest( '/asmi/overtones/.' ) );
});
gulp.task('clean', function(cb) {
var conn = ftp.create( {
host: process.env.FTP_HOST,
user: process.env.FTP_USER,
password: process.env.FTP_PASS,
parallel: 10,
log: gutil.log
} );
conn.rmdir('/asmi/overtones/', cb)
});