-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
89 lines (80 loc) · 2.38 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Author [email protected]
* Date 16/4/21
* Describe
*/
'use strict'
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var config = require('./package.json');
var header = require('gulp-header');
var umd = require("gulp-umd");
var path = require('path');
var livereload = require('gulp-livereload');
var moment = require('moment');
var uglifyOptions = {}
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @date <%= pkg.date %>',
'*/',
''].join('\n');
config.date = moment().format('YYYY-MM-DD HH:mm:ss');
var production = process.env.NODE_ENV === 'production';
gulp.task('build-js', function () {
return gulp.src([
'./src/xCharts.js',
'./src/utils/utils.js',
'./src/components/Component.js',
'./src/components/**/*.js',
'./src/charts/Chart.js',
'./src/charts/**/*.js',
// './src/charts/line.js',
])
.pipe(concat('./xCharts.js'))
.pipe(umd({
dependencies:function(){
return [
{
amd:"d3",
param:'d3',
global:'d3',
cjs:'d3'
}
]
},
exports: function () {
return 'xCharts';
},
namespace: function () {
return 'xCharts';
},
template:path.resolve(__dirname,'returnExportsGlobal.js')
}))
.pipe(header(banner, {pkg: config}))
.pipe(gulp.dest('./dist/'))
.pipe(uglify(uglifyOptions))
.pipe(rename({
suffix: '.min'
}))
.pipe(header(banner, {pkg: config}))
.pipe(gulp.dest('./dist/'));
});
gulp.task('build-css', function () {
return gulp.src('./src/css/xCharts.css')
.pipe(gulp.dest('./dist/'));
});
gulp.task('watch-reload', function () {
var server = livereload({start: true});
gulp.watch(['src/**/*.*', 'kaifa/*.*'], function (file) {
return gulp.src(file.path)
.pipe(livereload())
});
});
gulp.task('watch',function(){
gulp.watch(['src/**/*.js'],['build-js']);
gulp.watch(['src/**/*.css'],['build-css']);
})
gulp.task('build', ['build-js', 'build-css']);