-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
59 lines (56 loc) · 1.56 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
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const clear = require('clear');
const {rollup} = require('rollup');
const vue = require('rollup-plugin-vue2');
const babel = require('rollup-plugin-babel');
const uglify = require('rollup-plugin-uglify');
const moduleName = 'VueXdraggable';
const destName = 'vue-xdraggable';
// 检测代码风格
gulp.task('lint', () => {
clear();
return gulp.src(['src/**/*.js', 'src/**/*.vue', '!node_modules/**', '!dist/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
// 编译开发版本
gulp.task('build:dev', ['lint'], () => {
return rollup({
entry: 'src/index.js',
plugins: [vue(), babel()],
external: ['vue-xdraggable']
})
.then((bundle) => {
bundle.write({
moduleName,
format: 'umd',
dest: `dist/${destName}.js`,
sourceMap: true,
globals: {
'vue-xdraggable': 'VueXdraggable'
}
});
});
});
// 编译生产版本
gulp.task('build:prod', ['lint'], () => {
return rollup({
entry: 'src/index.js',
plugins: [vue(), babel(), uglify()],
external: ['vue-xdraggable']
})
.then((bundle) => {
bundle.write({
moduleName,
format: 'umd',
dest: `dist/${destName}.min.js`,
sourceMap: true,
globals: {
'vue-xdraggable': 'VueXdraggable'
}
});
});
});
gulp.task('default', ['lint', 'build:dev', 'build:prod']);