forked from l3tnun/EPGStation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
65 lines (57 loc) · 1.49 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
/* eslint-disable @typescript-eslint/no-var-requires */
'use strict';
const gulp = require('gulp');
const del = require('del');
const plumber = require('gulp-plumber');
const eslint = require('gulp-eslint');
const typescript = require('gulp-typescript');
const sourcemaps = require('gulp-sourcemaps');
// const minimist = require('minimist');
const src = ['./src/**/*.ts'];
const dist = './dist';
const tsconfig = require('./src/tsconfig.json');
/**
* 引数
* NODE_ENVに指定がなければ開発モードをデフォルトにする
*/
/*
const knownOptions = {
string: 'env',
default: { env: process.env.NODE_ENV || 'development' },
};
const options = minimist(process.argv.slice(2), knownOptions);
const isProduction = options.env === 'production';
*/
// clean
gulp.task('clean', () => {
return del([dist]);
});
// eslint
gulp.task('eslint', () => {
return gulp
.src(src)
.pipe(eslint({ useEslintrc: true }))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
// build
gulp.task(
'build',
gulp.series('clean', 'eslint', () => {
return gulp
.src(src)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(typescript(tsconfig.compilerOptions))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(dist));
}),
);
// watch
gulp.task(
'watch',
gulp.series('build', () => {
gulp.watch(src, gulp.task('build'));
}),
);
gulp.task('default', gulp.series('watch'));