forked from mozilla/distribution-viewer
/
gulpfile.babel.js
70 lines (59 loc) · 1.87 KB
/
gulpfile.babel.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
'use strict';
import gulp from 'gulp';
import autoprefixer from 'gulp-autoprefixer';
import browserSync from 'browser-sync';
import cleanCSS from 'gulp-clean-css';
import concat from 'gulp-concat';
import cp from 'child_process';
import eslint from 'gulp-eslint';
import jest from 'gulp-jest';
import nib from 'nib';
import path from 'path';
import sourcemaps from 'gulp-sourcemaps';
import stylus from 'gulp-stylus';
import webpack from 'webpack-stream';
const paths = {
root: './',
js: './distributionviewer/core/static/js',
css: './distributionviewer/core/static/css',
};
const bundles = {
css: {
main: [
path.resolve(paths.css, '**/*.styl'),
],
},
};
gulp.task('build:js', () => {
return gulp.src(path.resolve(paths.js, 'app/app.js'))
.pipe(webpack(require('./webpack.config.babel.js')))
.pipe(gulp.dest('./'));
});
gulp.task('build:css', () => {
gulp.src(bundles.css.main)
.pipe(sourcemaps.init())
.pipe(stylus({use: [nib()]}))
.pipe(autoprefixer())
.pipe(concat('bundle.css'))
.pipe(cleanCSS())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(paths.css))
.pipe(browserSync.stream());
});
gulp.task('watch', ['build'], () => {
gulp.watch([path.resolve(paths.js, '**/*.js'), '!' + path.resolve(paths.js, 'bundle.js')], ['build:js']);
gulp.watch(bundles.css.main, ['build:css']);
});
gulp.task('lint:js', ['build:js'], () => {
return gulp.src([path.resolve(paths.js, '**/*.js'), '!' + path.resolve(paths.js, 'bundle.js')])
.pipe(eslint('.eslintrc.json'))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('jest', ['build:js'], () => {
return gulp.src(path.resolve(paths.js, 'app/tests'))
.pipe(jest());
});
gulp.task('build', ['build:js', 'build:css']);
gulp.task('test', ['lint:js', 'jest']);
gulp.task('default', ['build']);