forked from zhangxiang958/vue-tab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
88 lines (76 loc) · 1.88 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
/**
* learning-gulp - gulpfile.js
* Created by mengdesen on 15/4/14.
* Last modified by nieweidong on 2015/04/15
*/
'use strict';
var gulp = require('gulp');
var webpack = require('gulp-webpack');
// var Webpack = require('webpack');
var named = require('vinyl-named');
var connect = require('gulp-connect');
var uglify = require('gulp-uglify');
gulp.task('connect', function(){
connect.server({
root: './src',
port: 8080,
livereload: true
});
});
var appList = ['app'];
gulp.task('bundle', function(){
return gulp.src(mapFiles(appList, 'js'))
.pipe(named())
.pipe(webpack({
entry: {
"index": "./src/app.js"
},
output: {
path: __dirname + '/lib',
filename: "app.js",
chunkFilename: "[name].js",
publicPath: './lib/'
},
module: {
loaders: [{
test: /\.vue$/,
loader: 'vue'
}, {
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
query: {
presets: ['es2015']
}
},{
test: /\.(png|jpg)$/,
loader: 'url'
}]
},
resolve: {
alias: {vue: 'vue/dist/vue.js'}
},
babel: {
presets: ['es2015'],
plugins: ['transform-runtime']
},
plugins: [
// new Webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js")
],
watch: true
}))
// .pipe(uglify())
.pipe(gulp.dest('src/lib/'))
.pipe(connect.reload());
});
gulp.task('uglify', function() {
return gulp.src(['src/lib/js/fastclick.js'])
.pipe(uglify())
.pipe(gulp.dest('src/lib/js/*.min.js'));
});
function mapFiles(list, extname) {
return list.map(function (app){
return 'src/' + app + '.' + extname;
});
};
gulp.task('default', ['bundle', 'connect']);