-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpfile.js
More file actions
118 lines (95 loc) · 2.86 KB
/
Gulpfile.js
File metadata and controls
118 lines (95 loc) · 2.86 KB
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
/*
## Available Tasks
### gulp build
compile sources in /build (uncompressed, sourcemap)
### gulp dist
compile the current distributable version in /dist (minified, without debug support)
### gulp start
starts a development session, rebuild the project on source change
### gulp test
run all the tests once
### gulp ci
start a continuous integration session
### gulp karma-start
start KarmaJS server
### gulp karma-run
trigger the execution of the tests on an active Karma server
*/
'use strict';
var pkg = require('./package.json');
var path = require('path');
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var react = require('gulp-react');
var cache = require('gulp-cached');
var runSequence = require('run-sequence');
var karma = require('karma');
var webpack = require('webpack');
var webpackBuild = require('gulp-webpack-build');
var webpackConfig = {
useMemoryFs: true,
progress: true
};
gulp.task('jshint', function () {
return gulp.src(['./src/**'])
.pipe(cache('jshint'))
.pipe(react())
.on('error', function(err) {
console.error('JSX ERROR in ' + err.fileName);
console.error(err.message);
this.end();
})
.pipe(jshint())
.pipe(jshint.reporter(stylish, { fail: true }))
.pipe(jshint.reporter('fail'))
;
});
gulp.task('build', ['jshint'], function() {
return gulp.src('./webpack.config.js', { base: path.resolve('./') })
.pipe(webpackBuild.configure(webpackConfig))
.pipe(webpackBuild.compile())
.pipe(gulp.dest('./'));;
});
gulp.task('dist', ['jshint'], function() {
return gulp.src('./webpack.config.js', { base: path.resolve('./') })
.pipe(webpackBuild.configure(webpackConfig))
.pipe(webpackBuild.overrides({
output: {
filename: './dist/[name]-' + pkg.version + '.js'
},
debug: false,
plugins: [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
]
}))
.pipe(webpackBuild.compile())
.pipe(gulp.dest('./'));
});
gulp.task('start', ['build'], function() {
gulp.watch(['./src/**'], ['build']);
});
gulp.task('test', ['jshint'], function() {
karma.server.start({
configFile: __dirname + '/karma.conf.js',
singleRun: true,
autoWatch: false
});
});
gulp.task('ci', ['jshint'], function() {
karma.server.start({
configFile: __dirname + '/karma.conf.js',
});
});
gulp.task('karma-start', ['jshint'], function() {
karma.server.start({
configFile: __dirname + '/karma.conf.js',
autoWatch: false
});
});
gulp.task('karma-run', ['jshint'], function() {
karma.runner.run({
configFile: __dirname + '/karma.conf.js',
});
});