forked from predixdesignsystem/px-file-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
97 lines (84 loc) · 2.28 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
'use strict';
const path = require('path');
const gulp = require('gulp');
const pkg = require('./package.json');
const $ = require('gulp-load-plugins')();
const gulpSequence = require('gulp-sequence');
const importOnce = require('node-sass-import-once');
const stylemod = require('gulp-style-modules');
const browserSync = require('browser-sync').create();
const gulpif = require('gulp-if');
const combiner = require('stream-combiner2');
const bump = require('gulp-bump');
const argv = require('yargs').argv;
const sassOptions = {
importer: importOnce,
importOnce: {
index: true,
bower: true
}
};
gulp.task('clean', function() {
return gulp.src(['.tmp', 'css'], {
read: false
}).pipe($.clean());
});
function handleError(err){
console.log(err.toString());
this.emit('end');
}
function buildCSS(){
return combiner.obj([
$.sass(sassOptions),
$.autoprefixer({
browsers: ['last 2 versions'],
cascade: false,
flexbox: false
}),
gulpif(!argv.debug, $.cssmin())
]).on('error', handleError);
}
gulp.task('sass', function() {
return gulp.src(['./sass/*.scss'])
.pipe(buildCSS())
.pipe(stylemod({
moduleId: function(file) {
return path.basename(file.path, path.extname(file.path)) + '-styles';
}
}))
.pipe(gulp.dest('css'))
.pipe(browserSync.stream({match: 'css/*.html'}));
});
gulp.task('watch', function() {
gulp.watch(['sass/*.scss'], ['sass']);
});
gulp.task('serve', function() {
browserSync.init({
port: 8080,
notify: false,
reloadOnRestart: true,
logPrefix: `${pkg.name}`,
https: false,
server: ['./', 'bower_components'],
});
gulp.watch(['css/*-styles.html', '*.html', '*.js', 'demo/*.html']).on('change', browserSync.reload);
gulp.watch(['sass/*.scss'], ['sass']);
});
gulp.task('bump:patch', function(){
gulp.src(['./bower.json', './package.json'])
.pipe(bump({type:'patch'}))
.pipe(gulp.dest('./'));
});
gulp.task('bump:minor', function(){
gulp.src(['./bower.json', './package.json'])
.pipe(bump({type:'minor'}))
.pipe(gulp.dest('./'));
});
gulp.task('bump:major', function(){
gulp.src(['./bower.json', './package.json'])
.pipe(bump({type:'major'}))
.pipe(gulp.dest('./'));
});
gulp.task('default', function(callback) {
gulpSequence('clean', 'sass')(callback);
});