-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
69 lines (60 loc) · 1.93 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
'use strict';
const gulp = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const cleanCSS = require('gulp-clean-css');
const rename = require('gulp-rename');
const sourcemaps = require('gulp-sourcemaps');
const uglify = require('gulp-uglify');
const typescript = require('gulp-typescript');
require('gulp-watch');
const plumber = require('gulp-plumber');
const browserSync = require('browser-sync').create();
gulp.task('reload', (done) => {
browserSync.reload();
done();
});
//sassコンパイル
gulp.task('sass', () => {
return gulp.src('app/css/customize.scss')
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(rename({extname: '.min.css'}))
.pipe(cleanCSS())
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.stream());
});
gulp.task('browser-sync', () => {
browserSync.init({
proxy: 'http://localhost/collatz_visualization',
port: 3011,
});
});
// tsをコンパイル
gulp.task('ts', () => {
return gulp.src('app/ts/customize.ts')
.pipe(plumber())
.pipe(typescript())
.js
.pipe(gulp.dest('app/js'));
});
//jsをminfyする
gulp.task('js-minify', () => {
return gulp.src(['./app/js/*.js', '!./app/js/*.min.js'])
.pipe(plumber())
.pipe(uglify())
.pipe(rename({extname: '.min.js'}))
.pipe(gulp.dest('./app/js/'))
.pipe(browserSync.stream());
});
//ファイル監視
gulp.task('watch', () => {
gulp.watch('app/css/customize.scss', gulp.task('sass'));
gulp.watch('app/index.html', gulp.task('reload'));
gulp.watch(['./app/ts/*.ts'], gulp.task('ts'));
gulp.watch(['./app/js/*.js', '!./app/js/*.min.js'], gulp.task('js-minify'));
});
gulp.task('deploy', gulp.series(gulp.parallel('sass','ts'),'js-minify'));
//デフォルト
gulp.task('default', gulp.series('deploy', gulp.parallel('browser-sync','watch')));