-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (58 loc) · 1.37 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
"use strict"
const gulp = require("gulp")
const webpack = require("gulp-webpack")
const browserSync = require("browser-sync");
const webpackConfig = {
"entry": {
"common": "./frontend/assets/js/common.js"
},
"output": {
"filename": `[name].bundle.js`
},
externals: {},
module: {
loaders: [
{ test: /\.js/,exclude: /node_modules/, loader: "babel" ,query:{presets:"es2015"}},
{ test: /\.html/, loader: "html" }
]
},
resolve: {
extensions:["",".js"],
alias:{
//"vue": process.cwd()+"/frontend/assets/js/libs/vue2.min.js"
}
},
plugins:[],
dev: true,
devtool: "source-map"
}
gulp.task("webpack",() => {
gulp.src([`frontend/assets/js/**/*.js`])
.pipe(webpack(webpackConfig))
.pipe(gulp.dest(`public/assets/js/`))
})
gulp.task("watch:webpack",() => gulp.watch([
"frontend/assets/js/**/*",
],["webpack"]) )
const browserSyncConfig = {
server:{
baseDir:"public"
},
open: "external",
//notify: false
}
gulp.task("server",() => {
browserSync(browserSyncConfig)
gulp.watch("public/**/*", () => {
setTimeout(function(){
browserSync.reload();
},500)
})
})
gulp.task("watch",[
"watch:webpack",
])
gulp.task("build",[
"webpack",
])
gulp.task("default",["watch","server"])