This repository has been archived by the owner on Aug 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
134 lines (115 loc) · 2.93 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
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var reactify = require('reactify');
var streamify = require('gulp-streamify');
var download = require('gulp-download');
var runSequence = require('run-sequence');
var path = {
HTML: 'web/src/index.html',
OUT: 'build.js',
MINIFIED_OUT: 'build.min.js',
DEST: 'web/dist',
DEST_BUILD: 'web/dist/build',
DEST_SRC: 'web/dist/src',
ENTRY_POINT: 'web/src/components/main.jsx',
IMAGES: ['web/src/images/**/*'],
DEST_IMAGES: 'web/dist/images',
DOWNLOADS: 'web/lib',
semanticUI: 'web/lib/semantic.min.js',
jQuery: 'web/lib/jquery.min.js'
};
var url = {
semanticUI: 'https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/1.12.3/semantic.min.js',
jQuery: 'https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js'
};
var browserifyArguments = {
transform: [reactify],
shim: {
'jQuery': {
path: path.jQuery,
exports: '$'
},
'semantic-ui': {
path: path.semanticUI,
exports: null,
depends: {
jQuery: 'jquery'
}
}
}
};
gulp.task('copyHTML', function () {
return gulp.src(path.HTML)
.pipe(gulp.dest(path.DEST));
});
gulp.task('copyImages', function () {
return gulp.src(path.IMAGES)
.pipe(gulp.dest(path.DEST_IMAGES));
});
gulp.task('downloadSemantic', function () {
return download(url.semanticUI)
.pipe(gulp.dest(path.DOWNLOADS));
});
gulp.task('downloadJQuery', function () {
return download(url.jQuery)
.pipe(gulp.dest(path.DOWNLOADS));
});
gulp.task('build', function () {
return gulp.src(path.ENTRY_POINT)
.pipe(browserify(browserifyArguments))
.pipe(rename(function (path) {
path.basename = 'app';
path.extname = '.js';
}))
.pipe(gulp.dest(path.DEST_BUILD));
});
gulp.task('buildUgly', function () {
return gulp.src(path.ENTRY_POINT)
.pipe(browserify(browserifyArguments))
.pipe(streamify(uglify()))
.pipe(rename(function (path) {
path.basename = 'app';
path.extname = '.js';
}))
.pipe(gulp.dest(path.DEST_BUILD));
});
gulp.task('production', function (callback) {
runSequence(
['copyHTML', 'copyImages'],
['downloadSemantic', 'downloadJQuery'],
'buildUgly',
callback
);
});
gulp.task('default', function (callback) {
runSequence(
['copyHTML', 'copyImages'],
['downloadSemantic', 'downloadJQuery'],
'build',
callback
);
});
// var source = require('vinyl-source-stream');
// var watchify = require('watchify');
// gulp.task('watch', function () {
// gulp.watch(path.HTML, ['copy']);
// var watcher = watchify(browserify({
// entries: [path.ENTRY_POINT],
// transform: [reactify],
// debug: true,
// cache: {},
// packageCache: {},
// fullPaths: true
// }));
// watcher.on('update', function () {
// watcher.bundle()
// .pipe(source(path.OUT))
// .pipe(gulp.dest(path.DEST_SRC));
// console.log('updated');
// })
// .bundle()
// .pipe(source(path.OUT))
// .pipe(gulp.dest(path.DEST_SRC));
// });