forked from egoist/corner-notie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
59 lines (51 loc) · 1.34 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
import gulp from 'gulp'
import serve from 'gulp-serve'
import webpack from 'webpack'
import gutil from 'gulp-util'
import path from 'path'
import {execSync} from 'child_process'
import webpackConfig from './webpack.config'
gulp.task('serve', serve({
port: 3746,
root: './demo'
}))
gulp.task('copy', () => {
execSync('npm run copy')
})
gulp.task('webpack', (cb) => {
let config = Object.create(webpackConfig)
config.output.libraryTarget = 'commonjs2'
config.output.library = true
config.output.path = path.resolve('./')
config.target = 'node'
let compiler = webpack(config)
compiler.run((err, stats) => {
if(err) throw new gutil.PluginError("webpack", err)
gutil.log("[webpack-webpack]", stats.toString({
colors: true
}))
cb()
})
})
gulp.task('browser', (cb) => {
let config = Object.create(webpackConfig)
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
}))
let compiler = webpack(config)
compiler.run((err, stats) => {
if(err) throw new gutil.PluginError("webpack", err)
gutil.log("[webpack-browser]", stats.toString({
colors: true
}))
cb()
})
})
gulp.task('watch', () => {
gulp.watch('./src/*', ['browser'])
gulp.watch('./browser/*', ['copy'])
})
gulp.task('build', ['browser'])
gulp.task('default', ['build', 'serve', 'watch'])