forked from lightningtgc/material-refresh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
72 lines (60 loc) · 1.86 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
var gulp = require('gulp');
var gUglify = require('gulp-uglify');
var gRename = require('gulp-rename');
var gStylus = require('gulp-stylus');
var gMinifyCSS = require('gulp-minify-css');
var gTranspile = require('gulp-es6-module-transpiler');
var del = require('del');
var projectName = 'material-refresh';
var jsName = projectName + '.js';
var jsMinName = projectName + '.min.js';
var cssName = projectName + '.css';
var cssMinName = projectName + '.min.css';
var devPath = './dev';
var buildPath = './build';
var paths = {
srcCSS: './src/css/*.styl',
srcJS: './src/js/main.js',
srcBase: './src/js',
destJS: devPath + '/js',
destCSS: devPath + '/css'
}
// clean
gulp.task('clean', function(cb){
del([devPath], cb);
});
// Handle CSS
gulp.task('stylus', ['clean'], function(){
gulp.src(paths.srcCSS)
.pipe(gStylus())
.pipe(gulp.dest(paths.destCSS))
.pipe(gMinifyCSS())
.pipe(gRename(cssMinName))
.pipe(gulp.dest(paths.destCSS));
});
// Handle JS
gulp.task('es6module', ['clean'], function(){
return gulp.src(paths.srcJS)
.pipe(gTranspile({
formatter: 'bundle',
basePath: paths.srcBase
}))
.pipe(gRename(jsName))
.pipe(gulp.dest(paths.destJS))
.pipe(gUglify())
.pipe(gRename(jsMinName))
.pipe(gulp.dest(paths.destJS));
});
// watch change
gulp.task('watch', function(){
gulp.watch(paths.srcCSS, ['stylus']);
});
gulp.task('default', [ 'stylus', 'es6module']);
gulp.task('build', ['stylus', 'es6module'], function(){
return gulp.src(devPath + '/*/*')
.pipe(gulp.dest(buildPath));
});
gulp.task('publish', ['stylus', 'es6module'], function(){
gulp.src([devPath + '/css/' + cssMinName, devPath + '/js/' + jsMinName])
.pipe(gulp.dest('./'));
});