-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
87 lines (75 loc) · 2.89 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
var gulp = require('gulp'),
stylus = require('gulp-stylus'),
webpack = require('gulp-webpack'),
user_story = require('gulp-user-story'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
rename = require('gulp-rename');
var webpack_output = 'allmychanges/static/allmychanges/js-compiled/react-site.js';
var webpack_config = {
output: {
filename: webpack_output
},
module: {
loaders: [
{
test: /\.js|\.jsx$/,
exclude: [
/node_modules\/ramda/
],
loader: "babel-loader"
},
{test: /\.styl$/, loader: "style!css!stylus"}
]
}//, externals: {"react": "React"}
};
var combiner = require('stream-combiner2');
gulp.task('webpack', function() {
// здесь мы используем combiner, как указано тут:
// https://github.com/gulpjs/gulp/blob/master/docs/recipes/combining-streams-to-handle-errors.md#combining-streams-to-handle-errors
// чтобы перехватить ошибки в цепочке обработчиков
var combined = combiner.obj([
gulp.src('allmychanges/static/allmychanges/js/react-site.js'),
webpack(webpack_config),
user_story(),
gulp.dest('./'),
uglify(),
rename({extname: '.min.js'}),
gulp.dest('./')]);
combined.on('error', console.error.bind(console));
return combined;
});
gulp.task('css', function() {
return gulp.src([
'allmychanges/static/allmychanges/stylus/{allmychanges,email}.styl',
'node_modules/react-mdl/extra/material.min.css'
])
.pipe(stylus())
.pipe(gulp.dest("allmychanges/static/allmychanges/css/"));
});
var source_js_files = [
'bower_components/lodash/lodash.js',
'node_modules/gulp-user-story/node_modules/user-story/lib/UserStory.js',
'node_modules/jquery/dist/jquery.js',
'node_modules/jquery.cookie/jquery.cookie.js',
'node_modules/jquery-sticky/jquery.sticky.js',
'node_modules/waypoints/lib/jquery.waypoints.js',
'allmychanges/static/spin.min.js', // TODO: это надо заменить на mdl.Spinner
'allmychanges/static/jquery.tile.js',
'bower_components/typeahead.js/dist/typeahead.jquery.js',
'bower_components/PubSubJS/src/pubsub.js',
// замена оригинала, потому что там мешает какой-то баг
// подробнее, в README react-mdl
'node_modules/react-mdl/extra/material.js',
webpack_output
];
var js_dest = 'allmychanges/static/allmychanges/js-compiled/';
gulp.task('js', ['webpack'], function() {
return gulp.src(source_js_files)
.pipe(concat('all.js'))
.pipe(gulp.dest(js_dest))
.pipe(uglify())
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest(js_dest));
});
gulp.task('default', ['css', 'js']);