-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.babel.js
93 lines (85 loc) · 1.98 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import gulp from 'gulp';
import sass from 'gulp-sass';
import webpack from 'webpack';
import browserSyncLib from 'browser-sync';
import runSequence from 'run-sequence';
import nodemon from 'gulp-nodemon';
import config from './src/js/config.js';
import gutil from 'gulp-util';
const browserSync = browserSyncLib.create();
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "./web/"
}
});
});
gulp.task('start-server', function() {
nodemon({
script: 'server.js',
ignore: ['*.*'],
env: { PORT: config.nodeServerPort }
});
});
gulp.task("webpack", function(callback) {
// run webpack
webpack({
entry: './src/js/index.js',
output: {
path: './web/js',
filename: 'app.bundle.js',
},
module: {
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
}]
},
resolve: {
alias: {
jquery: "jquery/src/jquery",
components: __dirname + '/src/js/components/'
}
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
]
}, function(err, stats) {
if(err) throw new gutil.PluginError("webpack", err);
// gutil.log("[webpack]", stats.toString({
// // output options
// }));
callback();
});
});
gulp.task('watch', function() {
gulp.watch("src/js/**/*.js", ['webpack']);
gulp.watch([
"web/**/*",
"!web/css/**/*"
], function(){
browserSync.reload();
});
});
gulp.task('init-dev', function() {
runSequence(
'webpack',
'browser-sync',
'watch'
);
});
gulp.task('build', ['webpack']);
gulp.task('serve', function() {
runSequence(
'start-server',
'init-dev'
)
});
gulp.task('default', ['init-dev']);