-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
63 lines (52 loc) · 1.76 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
var gulp = require('gulp'),
$ = require( "gulp-load-plugins" )({ pattern:['*', 'gulp-'] });
const babelConfig = {
presets: ['@babel/env', ['@babel/preset-react']],
plugins: ['@babel/proposal-object-rest-spread', '@babel/plugin-transform-destructuring']
}
function scss(){
return gulp.src('src/*.scss')
.pipe($.cssGlobbing({
extensions: '.scss'
}))
.pipe(
$.sass().on('error', $.sass.logError)
)
// .pipe($.combineMq()) // combine media queries
.pipe($.autoprefixer() )
.pipe($.cleanCss())
.pipe(gulp.dest('./dist'))
}
function react(){
const umdConf = {
exports: () => 'Switch'
}
return gulp.src('src/Switch.react.js')
.pipe( $.babel(babelConfig))
.pipe( $.umd(umdConf) )
.pipe( $.uglify() )
.pipe( gulp.dest('./dist/') )
}
/**
* gulp patch # makes v0.1.0 → v0.1.1
* gulp feature # makes v0.1.1 → v0.2.0
* gulp release # makes v0.2.1 → v1.0.0
*/
const inc = importance => () =>
// get all the files to bump version in
gulp.src('./package.json')
// bump the version number in those files
.pipe($.bump({type: importance}))
// save it back to filesystem
.pipe(gulp.dest('./'))
function gitTag(){
return gulp.src('./package.json')
// commit the changed version number
.pipe($.git.commit('bumps package version'))
.pipe($.tagVersion());
}
const build = gulp.parallel(scss, react)
exports.default = gulp.parallel(build)
exports.patch = gulp.series(inc('patch'), gitTag) // () => inc('patch')
exports.feature = gulp.series(inc('minor'), gitTag) // () => inc('minor')
exports.release = gulp.series(inc('major'), gitTag) // () => inc('major')