-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathgulpfile.js
More file actions
150 lines (129 loc) · 3.8 KB
/
Copy pathgulpfile.js
File metadata and controls
150 lines (129 loc) · 3.8 KB
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
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
koutoSwiss = require('kouto-swiss'),
prefixer = require('autoprefixer-stylus'),
jeet = require('jeet'),
rupture = require('rupture'),
minHtml = require('gulp-minify-html'),
browserSync = require('browser-sync'),
stylus = require('gulp-stylus'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
minifyCss = require('gulp-minify-css'),
imagemin = require('gulp-imagemin'),
concatCss = require('gulp-concat-css'),
deploy = require('gulp-gh-pages'),
gutil = require('gulp-util'),
source = require('vinyl-source-stream'),
browserify = require('browserify'),
watchify = require('watchify'),
reactify = require('reactify'),
notifier = require('node-notifier');
gulp.task('browser-sync', function () {
var files = [
'app/**/*.html',
'app/src/css/**/*.css',
'app/src/img/**/*',
];
browserSync.init(files, {
server: {
baseDir: 'build/'
}
});
});
gulp.task('imagemin', function() {
return gulp.src('app/src/img/**/*')
.pipe(imagemin({ optimizationLevel: 3, progressive: true, interlaced: true }))
.pipe(gulp.dest('build/img'));
});
gulp.task('react', function () {
var bundler = watchify(browserify({
entries: ['./app/src/jsx/app.jsx'],
transform: [reactify],
extensions: ['.jsx'],
debug: true,
cache: {},
packageCache: {},
fullPaths: true
}, watchify.args))
.on('update', function () { gutil.log('Rebundling...'); })
.on('time', function (time) {
gutil.log('Rebundled in:', gutil.colors.cyan(time + 'ms'));
});
bundler.transform(reactify);
bundler.on('update', rebundle);
function rebundle() {
return bundler.bundle()
.on('error', function (err) {
gutil.log(err);
notifier.notify({ title: 'Browserify Error', message: 'Something went wrong :/' });
})
.pipe(source('components.js'))
.pipe(gulp.dest('./build/js'))
.pipe(browserSync.reload({ stream: true }));
}
return rebundle();
});
gulp.task('scripts', function () {
var bundler = watchify(browserify({
entries: ['./app/src/js/main.js'],
extensions: ['.js'],
debug: true,
cache: {},
packageCache: {},
fullPaths: true
}, watchify.args))
.on('update', function () { gutil.log('Rebundling...'); })
.on('time', function (time) {
gutil.log('Rebundled in:', gutil.colors.cyan(time + 'ms'));
});
bundler.transform(reactify);
bundler.on('update', rebundle);
function rebundle() {
return bundler.bundle()
.on('error', function (err) {
gutil.log(err);
notifier.notify({ title: 'Browserify Error', message: 'Something went wrong :/' });
})
.pipe(source('main.js'))
.pipe(gulp.dest('./build/js'))
.pipe(browserSync.reload({ stream: true }));
}
return rebundle();
});
gulp.task('fonts', function(){
gulp.src('app/src/fonts/**/*')
.pipe(gulp.dest('build/fonts'))
});
gulp.task('stylus', function(){
gulp.src('app/src/styl/main.styl')
.pipe(plumber())
.pipe(stylus({
use:[koutoSwiss(), prefixer(), jeet(),rupture()],
compress: true
}))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('build/css'))
});
gulp.task('css', function(){
gulp.src('app/src/css/*.css')
.pipe(minifyCss())
.pipe(concatCss('plugins.min.css'))
.pipe(gulp.dest('build/css'))
});
gulp.task('html', function () {
gulp.src('app/**/*.html')
.pipe(gulp.dest('build/'))
});
gulp.task('watch', function () {
gulp.watch(['app/**/*.html'], ['html']);
gulp.watch('app/src/css/*.css', ['css']);
gulp.watch('app/src/styl/*.styl', ['stylus']);
gulp.watch('app/src/fonts/**/*', ['fonts']);
});
// just run gulp deploy-pages to send build files to gh-pages
gulp.task('deploy-pages', function () {
return gulp.src("build/**/*")
.pipe(deploy());
});
gulp.task('default', ['html', 'stylus', 'fonts', 'watch', 'react', 'scripts', 'css', 'browser-sync']);