forked from shiroari/redmine-burndown-chart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
136 lines (113 loc) · 2.87 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
'use strict';
var gulp = require('gulp'),
_ = require('gulp-load-plugins')(),
source = require('vinyl-source-stream'),
del = require('del'),
path = require('path'),
browserify = require('browserify'),
watchify = require('watchify'),
sourceFile = './src/scripts/main.js',
destFolder = './dist/scripts',
destFileName = 'app.js';
// App
gulp.task('app', function () {
return browserify({
entries: [sourceFile],
insertGlobals: true,
cache: {},
packageCache: {},
fullPaths: false,
debug: false
}).bundle()
.on('error', _.util.log.bind(_.util, 'Browserify Error'))
.pipe(source(destFileName))
.pipe(gulp.dest(destFolder));
});
gulp.task('app:watch', function () {
var bundler = watchify(browserify({
entries: [sourceFile],
insertGlobals: true,
cache: {},
packageCache: {},
fullPaths: true,
debug: true
}));
bundler.on('update', rebundle);
function rebundle() {
return bundler.bundle()
.on('error', _.util.log.bind(_.util, 'Browserify Error'))
.pipe(source(destFileName))
.pipe(gulp.dest(destFolder));
}
return rebundle();
});
// Styles
gulp.task('styles', function () {
gulp.src('./src/styles/**/*.scss')
.pipe(_.compass({
sass: 'src/styles',
css: 'dist/styles'
}))
//.pipe(_.autoprefixer('last 1 version'))
//.pipe(_.minifyCSS())
.pipe(gulp.dest('dist/styles'))
.pipe(_.size());
});
// HTML
gulp.task('html', function () {
return gulp.src('src/*.html')
.pipe(_.useref())
.pipe(gulp.dest('dist'))
.pipe(_.size());
});
gulp.task('jest', function () {
var nodeModules = path.resolve('./node_modules');
return gulp.src('src/scripts/**/__tests__/*')
.pipe(_.jest({
scriptPreprocessor: nodeModules + '/babel-jest',
unmockedModulePathPatterns: [nodeModules + '/react'],
globals: {
'BABEL_JEST_STAGE': 0,
'runtime': true
}
}));
});
// Clean
gulp.task('clean', function (cb) {
cb(del(['dist/*']), {
force: true
});
});
// Bundle
gulp.task('bundle', ['styles', 'app'], function () {
return gulp.src('./src/*.html')
.pipe(_.useref.assets())
//.pipe(_.useref.restore())
//.pipe(_.useref())
.pipe(gulp.dest('dist'));
});
// Webserver
gulp.task('serve', function () {
gulp.src('./dist')
.pipe(_.webserver({
livereload: true,
port: 9001
}));
});
// Robots.txt and favicon.ico
gulp.task('extras', function () {
return gulp.src(['src/*.txt', 'src/*.png'])
.pipe(gulp.dest('dist/'))
.pipe(_.size());
});
// Watch
gulp.task('watch', ['html', 'styles', 'app:watch', 'serve'], function () {
// Watch .html files
gulp.watch('src/*.html', ['html']);
// Watch .scss files
gulp.watch('src/styles/**/*.scss', ['styles']);
});
// Build
gulp.task('build', ['html', 'bundle', 'extras']);
// Default task
gulp.task('default', ['build', 'jest']);