forked from lbdremy/react-tooltip-component
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
125 lines (111 loc) · 3.27 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
'use strict';
var gulp = require('gulp');
var del = require('del');
var eslint = require('gulp-eslint');
var babel = require('gulp-babel');
var sass = require('gulp-sass');
var filter = require('gulp-filter');
var postcss = require('gulp-postcss');
var autoprefixer = require('autoprefixer');
var cssnano = require('cssnano');
var runSequence = require('run-sequence');
var webpackStatsHelper = require('./example/webpack-stats-helper');
var path = require('path');
var preProcess = require('gulp-preprocess');
var frep = require('gulp-frep');
var minifyHtml = require('gulp-minify-html');
var webpackStream = require('webpack-stream');
var webpackConfig = require('./webpack.config');
var exampleWebpackConfig = require('./example/webpack.prod.config');
var webpack = require('webpack');
gulp.task('lib:clean', function () {
del.sync(['lib', 'dist']);
});
gulp.task('lib:lint', function () {
return gulp
.src(['src/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
gulp.task('lib:babel', function () {
return gulp
.src(['src/**/*.js'])
.pipe(babel())
.pipe(gulp.dest('lib'));
});
gulp.task('lib:umd', function () {
return gulp
.src(['src/index.js'])
.pipe(webpackStream(webpackConfig, webpack))
.pipe(gulp.dest('dist'));
});
gulp.task('lib:sass', function () {
var cssFilter = filter('**/*.css');
return gulp
.src(['src/*.scss', '!src/_*.scss'])
.pipe(sass({outputStyle: 'expanded'}).on('error', sass.logError))
.pipe(cssFilter)
.pipe(gulp.dest('lib'))
.pipe(postcss([
autoprefixer({
browsers: [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
]
}),
cssnano({
safe: true,
discardComments: {removeAll: true}
})
]))
.pipe(gulp.dest('dist'));
});
gulp.task('lib:copy', function () {
return gulp
.src(['src/**/*', '!src/**/*.{scss,js}'])
.pipe(gulp.dest('lib'))
.pipe(gulp.dest('dist'));
});
gulp.task('lib', function (callback) {
runSequence('lib:clean', 'lib:lint', 'lib:babel', 'lib:umd', 'lib:sass', 'lib:copy', callback);
});
gulp.task('example:clean', function () {
del.sync(['example/dist']);
});
gulp.task('example:webpack', function () {
return gulp
.src(['example/app/app.js'])
.pipe(webpackStream(exampleWebpackConfig, webpack))
.pipe(gulp.dest('example/dist'));
});
gulp.task('example:html', function () {
var patterns = webpackStatsHelper.getReplacePatterns(path.join(__dirname, './example/dist/webpack.stats.json'));
return gulp.src(['example/app/*.html'])
.pipe(preProcess({
options: {
srcDir: path.join(__dirname, 'example/app')
}
}))
.pipe(frep(patterns))
.pipe(minifyHtml())
.pipe(gulp.dest('example/dist'));
});
gulp.task('example:copy', function () {
return gulp
.src(['example/app/*', '!example/app/*.{html,js}'], {nodir: true})
.pipe(gulp.dest('example/dist'));
});
gulp.task('example', function (callback) {
runSequence('example:clean', 'example:webpack', 'example:html', 'example:copy', callback);
});
gulp.task('build', function (callback) {
runSequence('lib', 'example', callback);
});