-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgulpfile.babel.js
executable file
·51 lines (42 loc) · 1.11 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
import gulp from 'gulp';
import del from 'del';
import run from 'run-sequence';
import path from 'path';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
import {
PATHS, WEBPACK_HOST, WEBPACK_PORT,
demo, devServerConf,
build, githubPagesConf
} from './webpack.conf';
gulp.task('clean', cb => del('dist/*', cb));
gulp.task('statics', () => {
return gulp.src('statics/**/*')
.pipe(gulp.dest('dist/statics'));
});
gulp.task('watch', () => {
gulp.watch('statics/**/*', ['statics']);
});
gulp.task('build', ['clean'], (cb) => {
webpack(build, function(err, stats) {
cb();
});
});
gulp.task('wp:dev', (cb) => {
const webpackDevServer = new WebpackDevServer(webpack(demo), devServerConf);
webpackDevServer.listen(WEBPACK_PORT, WEBPACK_HOST, (err, result) => {
console.log(err || 'Listening at %s:%s', WEBPACK_HOST, WEBPACK_PORT);
cb();
});
});
gulp.task('dev', cb => {
run('statics', 'watch', 'wp:dev');
});
gulp.task('wp:ghp', (cb) => {
webpack(githubPagesConf, function(err, stats) {
cb();
});
});
gulp.task('ghp', cb => {
run('build', 'wp:ghp');
});