-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
99 lines (87 loc) · 2.3 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
'use strict';
const gulp = require('gulp')
const babel = require('gulp-babel')
const eslint = require('gulp-eslint')
const sass = require('gulp-sass')
const sassLint = require('gulp-sass-lint')
const sourcemaps = require('gulp-sourcemaps')
const uglify = require('gulp-uglify')
const umd = require('gulp-umd');
const autoprefixer = require('gulp-autoprefixer')
const runSequence = require('run-sequence')
const rename = require('gulp-rename')
const conf = require('./package.json')
let DEVMODE = false
function fatalError(error) {
process.stderr.write(error.message + '\n')
process.exit(1)
}
gulp.task('scss-lint', function() {
if(DEVMODE === true) return;
//gulp.src('sass/**/*.s+(a|c)ss')
return gulp.src(['src/*.scss'])
.pipe(sassLint(
{
configFile: './scss-lint.yml'
}
))
.pipe(sassLint.format())
.pipe(sassLint.failOnError())
})
gulp.task('js-lint', function () {
if(DEVMODE === true) return;
return gulp.src(['src/FabBar.jsx'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
})
gulp.task('sass', function(cb) {
return gulp.src('src/index.scss')
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: DEVMODE ? 'expanded' : 'compressed'})
.on('error', fatalError))
.pipe(autoprefixer({
// See https://github.com/ai/browserslist#queries for what these queries means.
browsers: [
'last 2 versions',
'last 2 Android versions',
'last 2 ChromeAndroid versions',
'last 2 FirefoxAndroid versions']
}))
.pipe(rename(function(path) {
path.basename = conf.name + '-' + conf.version
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist/'))
})
gulp.task('react', function(cb) {
let tmp = gulp.src('src/index.jsx')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(umd({
exports: function (file) {
return 'FABBar';
},
namespace: function(file) {
return 'FABBar';
}
}));
if(!DEVMODE) {
tmp = tmp.pipe(uglify())
}
return tmp.pipe(rename(function(path) {
path.basename = conf.name + '-' + conf.version
}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'))
})
gulp.task('dev-build', function(cb) {
DEVMODE = true
runSequence(['build'], cb)
})
gulp.task('build', function(cb) {
runSequence(
['scss-lint', 'js-lint'],
['sass', 'react'],
cb);
})