-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
65 lines (58 loc) · 1.55 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
const gulp = require('gulp')
const eslint = require('gulp-eslint')
const clear = require('clear')
const { rollup } = require('rollup')
const babel = require('rollup-plugin-babel')({ babelrc: false, presets: ['es2015-rollup'] })
const uglify = require('rollup-plugin-uglify')
const ava = require('gulp-ava')
const moduleName = 'vueMethodsPromise'
const destName = 'vue-methods-promise'
// Test code style
gulp.task('lint', () => {
clear()
return gulp.src(['**/*.js', '!node_modules/**', '!dist/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
})
// Compiler development version
gulp.task('build:dev', ['lint'], () => {
return rollup({
entry: 'src/index.js',
plugins: [babel]
})
.then((bundle) => {
bundle.write({
moduleName,
format: 'umd',
dest: `dist/${destName}.js`,
sourceMap: true
})
})
})
// Compile production
gulp.task('build:prod', ['build:dev'], () => {
return rollup({
entry: 'src/index.js',
plugins: [babel, uglify()]
})
.then((bundle) => {
bundle.write({
moduleName,
format: 'umd',
dest: `dist/${destName}.min.js`,
sourceMap: true
})
})
})
// Component testing
gulp.task('test', ['build:prod'], () => {
return gulp.src('test/**.test.js')
.pipe(ava({
verbose: true // Enable verbose output
}))
})
gulp.task('default', ['lint', 'build:dev', 'build:prod', 'test'])
if (process.env.NODE_ENV !== 'production') {
gulp.watch(['**/**/**.js', '!node_modules/**', '!dist/**'], ['default'])
}