forked from mekwall/koa-webpack-dev-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
62 lines (51 loc) · 1.58 KB
/
Copy pathgulpfile.js
File metadata and controls
62 lines (51 loc) · 1.58 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
60
61
62
var path = require('path');
var gulp = require('gulp');
var runSequence = require('run-sequence');
var webpack = require('webpack');
var webpackConfig = require('./src/client/webpack.config.js');
var jade = require('gulp-jade');
gulp.task('default', function (cb) {
runSequence('build', 'dev', function () {
cb();
});
});
gulp.task('deploy', function (cb) {
runSequence('build', 'npm:deploy', function () {
cb();
});
});
gulp.task('build', function (callback) {
var debug = require('debug')('gulp:build');
var outputPath = path.join(process.cwd(), 'dist');
gulp.src('./src/client/*.jade')
.pipe(jade())
.pipe(gulp.dest(outputPath));
// modify some webpack config options
var config = Object.create(webpackConfig);
config.plugins = config.plugins.concat(
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
);
// run webpack
webpack(config, function (err, stats) {
if (err) {
throw new gutil.PluginError('webpack:build', err);
}
debug(stats.toString({ colors: true }));
callback();
});
});
gulp.task('dev', function () {
var Server = require('./src/index');
var compiler = webpack(require('../bonobo/config/webpack.js'));
var devServer = new Server(compiler, {
quiet: false,
contentBase: 'http://localhost:3000/'
});
devServer.listen(8080, function () {
console.log('Listening to 8080');
});
});
gulp.task('npm:deploy', function () {
});