forked from MrHuxu/easy-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
33 lines (29 loc) · 1.23 KB
/
gulpfile.js
File metadata and controls
33 lines (29 loc) · 1.23 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
var gulp = require('gulp');
var nodemon = require('gulp-nodemon');
var shell = require('gulp-shell');
var gutil = require('gulp-util');
var webpack = require('webpack');
var webpackDevServer = require('webpack-dev-server');
var webpackConfig = require('./webpack.config');
gulp.task("webpack", function(callback) {
webpack(webpackConfig, function(err, stats) {
if(err) throw new gutil.PluginError("webpack", err);
gutil.log("[webpack]", stats.toString());
callback();
});
});
gulp.task("webpack-dev-server", function(callback) {
webpackConfig.plugins = [new webpack.HotModuleReplacementPlugin()];
var compiler = webpack(webpackConfig);
new webpackDevServer(compiler, {
hot : true,
stats : { colors : true },
publicPath : '/assets/'
}).listen(6789, "localhost", function(err) {
if(err) throw new gutil.PluginError("webpack-dev-server", err);
gutil.log("[webpack-dev-server]", "http://localhost:6789/assets/bundle.js");
callback();
});
});
gulp.task('prd', ['webpack'], shell.task('NODE_ENV=production forever start server/bin/www --harmony'));
gulp.task('dev', ['webpack-dev-server'], shell.task('nodemon server/bin/www --harmony'));