forked from charismatic-invertebrates/stego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
155 lines (139 loc) · 4.25 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
'use strict';
var gulp = require('gulp');
var browserify = require('browserify');
var reactify = require('reactify');
var source = require('vinyl-source-stream');
var notify = require('gulp-notify');
var minifyCSS = require('gulp-minify-css');
var watchify = require('watchify');
var jasmine = require('gulp-jasmine');
var karma = require('karma').server;
var sass = require('gulp-sass');
var react = require('gulp-react');
var plumber = require('gulp-plumber');
var path = {
HTML_SRC: './client/src/*.html',
HTML_PUBLIC: './client/dist/public',
CSS_SRC: './client/src/css/style.scss',
CSS_PUBLIC: './client/dist/public/css',
ENTRY_POINT: './client/src/js/App.jsx',
OUT: 'bundle.js',
PUBLIC: './client/dist/public/js',
JS_SRC: './client/src/js/**.js',
IMAGES_SRC: './client/src/images/**',
IMAGES_PUBLIC: './client/dist/public/images',
BOWER_SRC: './client/src/bower_components/**',
BOWER_PUBLIC: './client/dist/bower_components',
SPEC: './spec/client/**.js',
JSX_SRC: './client/src/js/components/**',
JXS_OTHER_SRC: './client/src/js/stores/**',
SPEC_JSX_SRC: './spec/client/**',
COMPILED: './spec/compiled'
};
// Convert JSX templates to individual JS files
gulp.task('react', function() {
return gulp.src([path.JSX_SRC, path.JXS_OTHER_SRC, path.SPEC_JSX_SRC])
.pipe(react())
.pipe(gulp.dest(path.COMPILED));
});
gulp.task('test', function (done) {
// karma.start({
// configFile: __dirname + '/karma.conf.js',
// singleRun: true
// }, done);
return gulp.src([path.SPEC])
.pipe(jasmine());
});
// Copy image files to dist
gulp.task('images', function(){
gulp.src([path.IMAGES_SRC])
.pipe(gulp.dest(path.IMAGES_PUBLIC))
.pipe(notify('Stego assets have been copied over!'));
});
// Copy bower components to dist
gulp.task('bower', function(){
gulp.src([path.BOWER_SRC])
.pipe(gulp.dest(path.BOWER_PUBLIC))
.pipe(notify('Bower components have been copied over!'));
});
// Copy HTML file to dist
gulp.task('html', function(){
return gulp.src([path.HTML_SRC])
.pipe(gulp.dest(path.HTML_PUBLIC))
.pipe(notify('Stego HTML Build Complete!'));
});
// HTML Watch task
gulp.task('watch-html', function(){
gulp.watch(path.HTML_SRC, function(){
return gulp.src([path.HTML_SRC])
.pipe(gulp.dest(path.HTML_PUBLIC))
.pipe(notify('WATCH: Stego HTML Build Complete!'));
});
});
// Compile JSX file to build.js
gulp.task('jsx', function(){
browserify({
entries: [path.ENTRY_POINT],
transform: [reactify]
})
.bundle()
.pipe(source(path.OUT))
.pipe(gulp.dest(path.PUBLIC))
.pipe(notify('Stego JSX Build Complete!'));
});
// JSX Watch task
gulp.task('watch-jsx', function(){
var watcher = watchify(browserify({
entries: [path.ENTRY_POINT],
transform: [reactify],
debug: true,
cache: {}, packageCache: {}, fullPaths: true
}));
return watcher.on('update', function(){
watcher.bundle()
.pipe(plumber())
.pipe(source(path.OUT))
.pipe(gulp.dest(path.PUBLIC))
.pipe(notify('WATCH: Stego JS Build Complete!'));
})
.bundle()
.pipe(source(path.OUT))
.pipe(gulp.dest(path.PUBLIC));
});
// Compile Sass and minify styles files to dist
gulp.task('css', function(){
gulp.src(path.CSS_SRC)
.pipe(sass())
.pipe(minifyCSS())
.pipe(gulp.dest(path.CSS_PUBLIC))
.pipe(notify('Stego CSS Build Complete!'));
});
// Sass/CSS Watch task
gulp.task('watch-css', function(){
gulp.watch(path.CSS_SRC, function(){
gulp.src(path.CSS_SRC)
.pipe(plumber())
.pipe(sass())
.pipe(minifyCSS())
.pipe(gulp.dest(path.CSS_PUBLIC))
.pipe(notify('WATCH: Stego Styles Build Complete!'));
});
});
// Copy non-JSX Javascript files to dist
gulp.task('js', function(){
gulp.src([path.JS_SRC])
.pipe(gulp.dest(path.PUBLIC))
.pipe(notify('JS sources have been copied over!'));
});
// Watch for changes in non-JSX Javscript files
gulp.task('watch-js', function(){
gulp.watch(path.JS_SRC, function(){
return gulp.src([path.JS_SRC])
.pipe(plumber())
.pipe(gulp.dest(path.PUBLIC))
.pipe(notify('JS sources have been copied over!'));
});
});
// When "gulp" is run in the terminal, this is what will be called
gulp.task('build', ['jsx', 'js', 'html', 'css', 'images', 'bower']);
gulp.task('default', ['watch-js', 'watch-jsx', 'watch-html', 'watch-css']);