-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
79 lines (69 loc) · 1.88 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const gulp = require('gulp');
const typescript = require('gulp-typescript');
const pug = require('gulp-pug');
const notify = require("gulp-notify");
const plumber = require("gulp-plumber");
const browserSync = require("browser-sync");
const webpackStream = require("webpack-stream");
const webpack = require("webpack");
// webpackの設定ファイルの読み込み
const webpackConfig = require("./webpack.config");
gulp.task('webpack', (done) => {
// ☆ webpackStreamの第2引数にwebpackを渡す☆
webpackStream(webpackConfig, webpack)
.pipe(gulp.dest("docs"));
done();
});
//setting : paths
var paths = {
'pug': './src/pug/',
'html': './docs/',
'ts': './src/ts/',
'js': './src/js/'
}
//setting : Pug Options
var pugOptions = {
pretty: true
}
gulp.task('ts', (done) => {
var options ={
"module": "es2015",
}
gulp.src([paths.ts + '*.ts'])
.pipe(typescript(options))
.pipe(gulp.dest(paths.js));
done();
});
gulp.task('pug', (done) => {
gulp.src(paths.pug + '*.pug')
.pipe(plumber({ errorHandler: notify.onError("Error: <%= error.message %>") }))
.pipe(pug(pugOptions))
.pipe(gulp.dest(paths.html));
done();
});
//Browser Sync
gulp.task('browser-sync', (done) => {
browserSync({
server: {
baseDir: paths.html
}
});
gulp.watch('./docs/*.js', gulp.task('reload'));
gulp.watch(paths.html + "*.html", gulp.task('reload'));
done();
});
gulp.task('reload', (done) => {
browserSync.reload();
done();
});
//watch
gulp.task('watch', function (done) {
gulp.watch(paths.ts + '*.ts', gulp.task('ts'));
gulp.watch(paths.pug + '*.pug', gulp.task('pug'));
gulp.watch(paths.js + '*.js', gulp.task('webpack'));
done();
});
gulp.task('default', gulp.series('browser-sync', 'watch', (done) => {
console.log('task default');
done();
}));