-
Notifications
You must be signed in to change notification settings - Fork 86
/
gulpfile.js
81 lines (67 loc) · 1.73 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
var gulp = require('gulp');
var gutil = require('gulp-util');
var browserify = require('browserify');
var watchify = require('watchify');
var babelify = require('babelify');
var vueify = require('vueify');
var stylus = require('gulp-stylus');
var source = require('vinyl-source-stream');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var insert = require('gulp-insert');
var rename = require('gulp-rename');
var template =
"/*! Copyright (c) 2016 Naufal Rabbani (http://github.com/BosNaufal)\n\
* Licensed Under MIT (http://opensource.org/licenses/MIT)\n\
*\n\
* Vue Mini Shop - Version@1.0.0\n\
*\n\
*/"
function scripts() {
var b = browserify({
entries: ['./assets/js/main.js'],
debug: true,
cache: {},
packageCache: {},
fullPaths: true,
transform: [babelify, vueify],
plugin: [watchify]
});
function bundling() {
b.bundle()
.pipe(source('build.js'))
.pipe(gulp.dest('./assets/js/build/'));
}
b.on('update', function () {
gutil.log('bundling~');
bundling();
return gulp.src('./assets/js/build/build.js')
.pipe(uglify('min'))
.pipe(insert.prepend(template))
.pipe(rename('build.min.js'))
.pipe(gulp.dest('./assets/js/build/'));
});
b.on('time', function (time) {
if(time >= 1000){
time = time/1000+' ms';
}else{
time = time+' μs';
}
gutil.log('bundled! in '+time);
});
bundling();
}
gulp.task('build-css',function () {
return gulp.src('./assets/stylus/main.styl')
.pipe(sourcemaps.init())
.pipe(stylus({
compress: true
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./assets/css/'));
});
gulp.task('dev', function () {
gulp.watch('./assets/stylus/**/*.styl',['build-css']);
return scripts();
});
gulp.task('default', ['dev']);