-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
48 lines (40 loc) · 1.08 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
import gulp from 'gulp'
import gulpLoadPlugins from 'gulp-load-plugins'
import buffer from 'vinyl-buffer'
import source from 'vinyl-source-stream'
import browserify from 'browserify'
import babelify from 'babelify'
const plugins = gulpLoadPlugins()
const transform = (env) => {
let transformSource = browserify({
entries: './src/javascript/sjfScroll.js',
standalone: 'SjfScroll',
transform: babelify,
debug: env === 'dev' ? true : false
})
.bundle()
.pipe(source('SjfScroll.js'))
.pipe(buffer())
let result = transformSource
if (env === 'dev') {
result = result.pipe(gulp.dest('build/'))
} else {
result = result
.pipe(plugins.uglify())
.pipe(plugins.rename('./sjfScroll.min.js'))
.pipe(gulp.dest('dist/'))
}
return result
}
// server处理
gulp.task('dev', function () {
gulp.watch(['src/javascript/*.js'], ['transform']);
})
// js处理
gulp.task('transform', function () {
return transform('dev')
})
gulp.task('build', function () {
return transform('prod')
})
gulp.task('default', ['build'])