-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.babel.js
68 lines (57 loc) · 1.49 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
import gulp from 'gulp'
import babel from 'gulp-babel'
import sequence from 'run-sequence'
import del from 'del'
import colors from 'colors'
import webpack from 'webpack-stream'
gulp.task('default', done => sequence(['clean'], ['build'], done))
gulp.task('clean', () => del(['lib']))
gulp.task('build', ['build:lib'])
gulp.task('build:lib', () => {
return gulp.src(['src/**/*.js'])
.pipe(babel({
presets: ['env']
}))
.on('error', function (error) {
console.log(error.stack)
this.emit('end')
})
.pipe(gulp.dest('lib'))
})
gulp.task('xbuild:lib', () => {
return gulp.src(['babel-polyfill', 'src/prerender.js'])
.pipe(webpack({
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env']
}
}
}
]
}
}))
.pipe(gulp.dest('lib/'))
})
gulp.task('watch', ['build:lib'], () => {
const watcher = gulp.watch(['src/**/*.js'], ['build:lib'])
watcher.on('change', (obj) => {
const _path = obj.path.split('/')
let path = []
if (_path[_path.length - 3]) {
path.push(_path[_path.length - 3])
}
if (_path[_path.length - 2]) {
path.push(_path[_path.length - 2])
}
if (path.length > 0) {
path = path.join('/')
}
console.log(colors.yellow(`[vue-gettext-tools] [watcher] => File "${path}" was changed.`))
})
})