forked from marcelodolza/iziToast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (51 loc) · 1.63 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
var gulp = require( 'gulp' );
var concat = require( 'gulp-concat' );
var stylus = require('gulp-stylus');
var size = require( 'gulp-size' );
var jshint = require( 'gulp-jshint' );
var notify = require( 'gulp-notify' );
var uglify = require( 'gulp-uglify' );
var csso = require( 'gulp-csso' );
var catchError = function(err) {
console.log(err.toString())
this.emit('end')
}
/**
* Styl task
**/
gulp.task('styl', function () {
return gulp.src('./src/css/style.styl')
.pipe(stylus())
.on('error', catchError)
.pipe( concat( 'iziToast.css' ) )
.pipe( gulp.dest( './dist/css' ) )
.pipe( concat( 'iziToast.min.css' ) )
.pipe( csso({discardComments: false}) )
.pipe( gulp.dest( './dist/css' ) )
.pipe( notify( 'Stylus build done successfully!' ) )
.pipe( size({ showFiles: true }) );
});
/**
* Scripts task
**/
gulp.task( 'scripts', function() {
return gulp.src( './src/js/iziToast.js' )
.pipe( jshint() )
.pipe( jshint.reporter('default') )
.pipe( concat( 'iziToast.min.js' ) )
.pipe( uglify( { mangle: true } ) )
.pipe( gulp.dest( './dist/js' ) )
.pipe( notify( 'Scripts build done successfully!' ) )
.pipe( size({ showFiles: true }) );
});
/**
* Watch task
**/
gulp.task('watch', ['styl','scripts'], function() {
gulp.watch('./src/css/**/*.styl', [ 'styl' ]) // watch for changes and run the css task
gulp.watch('./src/js/**/*.js', [ 'scripts' ]) // watch for changes and run the js task
})
/**
* Default task
**/
gulp.task( 'default', [ 'styl', 'scripts' ] );