forked from shri-2015-org/shriek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (66 loc) · 1.91 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
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var nano = require('gulp-cssnano');
var bower = require('gulp-bower');
var wiredep = require('wiredep').stream;
var prefix = require('gulp-autoprefixer');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var reactify = require('reactify');
var path = {
HTML: 'app/views/layouts/index.html',
MINIFIED_OUT: 'assets/js/components.min.js',
REACT_COMPONENTS: 'app/views/components/*.jsx',
ALT_ACTIONS: 'app/actions/*.js',
ALT_STORES: 'app/stores/*.js',
OUT: 'app/assets/js/components.js',
SASS_FILE: 'app/assets/css/*.sass',
DEST: 'public',
DEST_BUILD: 'public',
DEST_SRC: 'dist/assets',
ENTRY_POINT: 'app/assets/js/app.jsx',
BOWER_DIR: 'app/components',
IMGS: 'app/assets/img/**/*'
};
gulp.task('default', ['bower', 'sass', 'build', 'watch']);
// watch
gulp.task('watch', function () {
gulp.watch([path.SASS_FILE], ['sass']);
gulp.watch(['bower.json'], ['bower']);
gulp.watch([
path.ENTRY_POINT,
path.REACT_COMPONENTS,
path.ALT_ACTIONS,
path.ALT_STORES
], ['build']);
});
gulp.task('bower', function () {
return bower({cmd: 'update'});
});
// react components
gulp.task('build', function () {
browserify({
entries: [path.ENTRY_POINT],
transform: [reactify]
})
.on('error', function (err) {console.log(err);})
.bundle()
.pipe(source(path.MINIFIED_OUT))
.pipe(gulp.dest(path.DEST_BUILD));
});
// images
gulp.task('images', function () {
return gulp.src(path.IMGS)
.pipe(gulp.dest('./public/assets/img'));
});
// sass
gulp.task('sass', ['images'], function () {
return gulp.src('app/assets/css/**/*.sass')
.pipe(sass().on('error', sass.logError))
.pipe(concat('bundle.min.css'))
.pipe(prefix({browsers: ['last 2 version']}))
.pipe(nano({zindex: false}))
.pipe(gulp.dest('./public/assets/css'));
});