-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
55 lines (43 loc) · 1.37 KB
/
gulpfile.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
var gulp = require('gulp');
var templateCache = require('gulp-angular-templatecache');
var gutil = require('gulp-util');
var webpack = require('webpack');
var webpackConfig = require('./webpack.config.js');
var WebpackDevServer = require('webpack-dev-server');
var webpackDevCfg = Object.create(webpackConfig);
webpackDevCfg.devtool = 'eval-source-map';
webpackDevCfg.debug = true;
webpackDevCfg.output.pathinfo = true;
webpackDevCfg.cache = true;
webpackDevCfg.watch = true;
var devCompiler = webpack(webpackDevCfg);
gulp.task('tpl-cache', function() {
return gulp.src('app/**/*html')
.pipe(templateCache({
standalone: true
}))
.pipe(gulp.dest('app'));
});
gulp.task('watch:html', function() {
return gulp.watch(['app/**/*.html'], ['tpl-cache']);
});
gulp.task('webpack:dev-server', function(callback) {
new WebpackDevServer(devCompiler, {
contentBase: 'public',
hot: true,
filename: 'bundle.js',
watchOptions: {
aggregateTimeout: 300,
poll: 1000
}
}).listen(8080, 'localhost', function(err) {
if (err) throw new gutil.PluginError('webpack-dev-server', err);
gutil.log('[webpack-dev-server]', 'http://localhost:8080/webpack-dev-server/index.html');
callback();
});
});
gulp.task('json-server', function() {
require('./index');
});
gulp.task('default', ['json-server', 'watch:html', 'webpack:dev-server']);