forked from dai-siki/vue-image-crop-upload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
116 lines (106 loc) · 2.67 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/******************************************************
* ----前端工程自动化构建---- *
* *
* @author dai-siki同学 < [email protected] > *
******************************************************/
// import package
const $ = require('gulp-load-plugins')(),
webpack = require('webpack-stream'),
named = require('vinyl-named'),
browserSync = require('browser-sync').create(),
reload = browserSync.reload,
gulp = require('gulp');
/** 开发
-------------------------------------------------------------*/
gulp.task('css', function() {
gulp.src('./scss/*.scss').pipe($.sass()).pipe($.autoprefixer('last 10 version')).pipe(gulp.dest('./'));
});
// jS task
gulp.task('js', function() {
var webpack_config = {
module: {
loaders: [{
test: /\.js$/,
loader: 'babel',
query: {
presets: [
'es2015', 'stage-3'
],
plugins: [
['transform-runtime', {
helpers: false,
polyfill: false,
regenerator: true
}]
]
}
}, {
test: /\.css$/,
loaders: ['style', 'css']
}, {
test: /\.json$/,
loaders: ['json']
}, {
test: /\.(scss|sass)$/,
loaders: ['style', 'css', 'sass']
}, {
test: /\.(html|tpl)$/,
loaders: ['html']
}, {
test: /\.vue$/,
loaders: ['vue']
}]
}
};
gulp.src('./example/demo.js')
.pipe($.plumber({
errorHandler: _errrHandler
}))
.pipe(named(function() {
return 'demo-src';
}))
.pipe(webpack(webpack_config)) /*.pipe($.uglify())*/
.pipe(gulp.dest('./example'));
gulp.src('./example-2/demo.js')
.pipe($.plumber({
errorHandler: _errrHandler
}))
.pipe(named(function() {
return 'demo-src';
}))
.pipe(webpack(webpack_config)) /*.pipe($.uglify())*/
.pipe(gulp.dest('./example-2'));
gulp.src('./example-3/demo.js')
.pipe($.plumber({
errorHandler: _errrHandler
}))
.pipe(named(function() {
return 'demo-src';
}))
.pipe(webpack(webpack_config)) /*.pipe($.uglify())*/
.pipe(gulp.dest('./example-3'));
});
gulp.task('serve', function() {
browserSync.init({
server: {
baseDir: './'
}
});
gulp.watch([
'./example-3/demo.js', './example-2/demo.js', './example/demo.js', './*.vue', './*.css'
], ['js']);
gulp.watch(['./scss/*.scss'], ['css']);
gulp.watch([
'./example/**/*.html', './example/demo-src.js', './example-2/**/*.html', './example-2/demo-src.js', './example-3/**/*.html', './example-3/demo-src.js'
], function() {
reload();
});
});
gulp.task('default', ['serve']);
/** 辅助函数
-------------------------------------------------------------*/
//错误提示
function _errrHandler(e) {
$.util.beep();
$.util.log(e);
}