forked from G-Node/gin-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
75 lines (63 loc) · 1.62 KB
/
gulpfile.babel.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
import gulp from "gulp"
import copy from "gulp-copy"
import uglify from "gulp-uglify"
import sourcemaps from "gulp-sourcemaps"
import named from "vinyl-named"
import connect from "gulp-connect"
import webpack from "webpack-stream"
/*
* Build configuration
*/
const webpack_config = {
module: {
loaders: [
{ test: /\.vue$/, loader: "vue" },
{ test: /\.js$/, loader: "babel", exclude: /node_modules/ },
{ test: /\.json$/, loader: "json" }
]
},
output: {
filename: "[name].js"
},
devtool: "source-map"
}
const copy_files = [
"src/index.html"
]
const connect_config = {
port: 8080,
livereload: false,
root: "build",
index: "index.html",
fallback: "build/index.html"
}
/*
* Define tasks
*/
gulp.task("vue", () => {
return gulp.src(["src/js/main.js"])
.pipe(named())
.pipe(webpack(webpack_config))
.pipe(gulp.dest("build/js/"))
.pipe(connect.reload())
})
gulp.task("vue-minify", ["vue"], () => {
return gulp.src(["build/js/main.js"])
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(uglify({ mangle: false }))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("build/js/"))
.pipe(connect.reload())
})
gulp.task("copy", () => {
return gulp.src(copy_files)
.pipe(copy("build", { prefix: 1 }))
.pipe(connect.reload())
})
gulp.task("watch", ["vue", "copy"], () => {
return gulp.watch("src/**/*", ["vue", "copy"])
})
gulp.task("dev", ["watch"], () => {
return connect.server(connect_config)
})
gulp.task("default", ["vue-minify", "copy"])