This repository has been archived by the owner on Mar 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
101 lines (90 loc) · 3.1 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
var gulp = require('gulp'),
karmaServer = require('karma').Server;
gulp.task('scripts', function browserify_components() {
// Compile our core.components.
var babelify = require('babelify'),
browserify = require('browserify'),
buffer = require('vinyl-buffer'),
rename = require('gulp-rename'),
source = require('vinyl-source-stream'),
sourcemaps = require('gulp-sourcemaps'),
streamify = require('gulp-streamify'),
uglify = require('gulp-uglify');
return browserify({
entries: ['js/core.js'],
insertGlobals: true
})
// babel transforms our JS from es6/es2015 to parsable js in the browser
// and also the React JSX style syntax we have
.transform(babelify, {presets: ['es2015']})
.bundle()
.pipe(source('core.browserify.js'))
.pipe(buffer())
// We must use buffer to load the whole file in order to generate sourcemaps
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write({includeContent: false, sourceRoot: './js/'}))
// Write an unminified file
.pipe(gulp.dest('./dist/'))
// Minify
.pipe(streamify(uglify()))
.pipe(rename({
extname: '.min.js'
}))
// Write the minified vile
.pipe(gulp.dest('./dist/'));
});
gulp.task('css', function (done) {
var args = require('yargs').argv;
var postcss = require('gulp-postcss');
var sourcemaps = require('gulp-sourcemaps');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var stylus = require('gulp-stylus');
var processors = [
//require('postcss-import')(),
require('autoprefixer')({browsers: 'last 2 version'}),
require('postcss-custom-properties')(),
require('postcss-calc')(),
require('postcss-custom-media')(),
require('postcss-media-minmax')()
];
return individualTask = gulp.src('./styls/core.styl')
.pipe(sourcemaps.init())
.pipe(stylus({
compress: false,
'include css': true
}))
.pipe(postcss(processors))
.pipe(sourcemaps.write('.', {includeContent: false}))
.pipe(gulp.dest('./css/'))
.pipe(minifyCss())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('./css/'));
});
gulp.task('karma', function karma(done){
new karmaServer({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, function() {
done();
// Clean the tests after karma has ran here
// because we need to kill the process after karma exits.
process.exit();
}).start();
});
gulp.task('karma_watch', function karma_watch(done) {
new karmaServer({
configFile: __dirname + '/karma.conf.js',
autoWatch: true,
singleRun: false,
usePolling: true
}, function() {
done();
process.exit();
}).start();
});
//gulp.task('test', gulp.series(karma));
//gulp.task('test', gulp.series(tasks.scripts.js_hint, karma));
module.exports = gulp;