-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
59 lines (52 loc) · 1.54 KB
/
gulpfile.js
File metadata and controls
59 lines (52 loc) · 1.54 KB
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
var gulp = require('gulp')
var gutil = require('gulp-util')
var webpack = require('webpack')
var webpackConfig = require('./web/build/webpack.prod.conf.js')
var open = require("gulp-open")
var clean = require('gulp-clean')
var spawn = require('child_process').spawn
var watch = false
gulp.task('clean', function() {
return gulp.src('./web/dist', {
read: false
}).pipe(clean())
})
gulp.task('copy', function () {
// Copy html
gulp.src('./web/index.html')
.pipe(gulp.dest('web/dist'))
})
gulp.task('webpack', function (callback) {
var myConfig = Object.create(webpackConfig)
myConfig.plugins = myConfig.plugins.concat(
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
)
myConfig.watch = watch
webpack(myConfig, function (err, stats) {
if (err) throw new gutil.PluginError('build', err)
gutil.log('[build]', stats.toString({
colors: true
}))
if (process.platform === 'darwin') {
spawn('osascript', ['-e', 'display notification "App recompiled" with title "xikbot-web"'])
}
if (!watch) {
callback()
}
})
})
// Production build
gulp.task('build', ['clean'], function () {
gulp.start('copy', 'webpack')
})
gulp.task('watch', ['clean'], function () {
watch = true
gulp.start('copy', 'webpack')
})
gulp.task('default', ['build'])