-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.babel.js
71 lines (60 loc) · 1.65 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const gulp = require('gulp')
const babel = require('gulp-babel')
const gulpWebpack = require('webpack-stream')
const webpack = require('webpack')
const eslint = require('gulp-eslint')
gulp.task('lint', () => (
gulp.src('src/**/*.js')
.pipe(eslint({ fix: true }))
.pipe(eslint.format())
.pipe(gulp.dest('src'))
))
gulp.task('babel', () => (
gulp.src('src/**/*.js')
.pipe(eslint({ fix: true }))
.pipe(eslint.format())
.pipe(babel())
.pipe(gulp.dest('dist'))
))
gulp.task('test', () => (
gulp.src('browser/nilbog.min.js')
.pipe(gulp.dest('test/browser/js'))
))
gulp.task('webpack', () => (
gulp.src('src/index.js')
.pipe(gulpWebpack({
output: {
filename: 'nilbog.min.js',
library: 'Nilbog'
},
mode: 'production',
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
}
]
}
}, webpack))
.pipe(gulp.dest('browser'))
))
gulp.task('js:prod', gulp.series(['lint', 'babel', 'webpack']))
gulp.task('babel:watch', () => (
gulp.watch('src/**/*.js', gulp.series('babel'))
))
gulp.task('js:dev', gulp.series(['babel', 'webpack', 'test']))
gulp.task('webpack:watch', () => (
gulp.watch(['src/**/*.js'], gulp.series('webpack'))
))
gulp.task('test:watch', () => (
gulp.watch(['browser/nilbog.min.js'], gulp.series('test'))
))
gulp.task('js:dev:watch', gulp.parallel('babel:watch', 'webpack:watch', 'test:watch'))
gulp.task('default', gulp.series(['js:dev:watch']))