-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgulpfile.js
60 lines (53 loc) · 1.67 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
'use strict';
var path = require('path');
var gulp = require('gulp');
var babel = require('gulp-babel');
var includeFile = require('gulp-include-file');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
var less = require('gulp-less');
var minifyCss = require('gulp-clean-css');
var prefixer = require('gulp-autoprefixer');
var cssDir = path.join(__dirname, '/less');
var libDir = path.join(__dirname, '/lib');
var distDir = path.join(__dirname, '/dist');
var nodeModulesDir = path.join(__dirname, '/node_modules');
function processStyles(dir) {
var files = [
path.join(nodeModulesDir, '/bubbletree/dist/bubbletree.css'),
path.join(nodeModulesDir, '/pivottable/dist/pivot.min.css'),
path.join(nodeModulesDir, '/c3/c3.min.css'),
path.join(cssDir, '/build.less')
];
return gulp.src(files)
.pipe(sourcemaps.init())
.pipe(less())
.pipe(prefixer({browsers: ['last 4 versions']}))
.pipe(minifyCss({compatibility: 'ie8'}))
.pipe(concat('babbage.css'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(dir));
}
gulp.task('default', [
'lib.scripts',
'lib.styles',
'dist.styles'
]);
gulp.task('lib.scripts', function() {
return gulp.src([
path.join(nodeModulesDir, '/bubbletree/node_modules/tween.js/src/Tween.js'),
path.join(nodeModulesDir, '/bubbletree/dist/bubbletree.min.js'),
path.join(__dirname, '/src/**/*.js')
])
.pipe(includeFile({
regex: /require\s*\(\s*['"]([^'"]*\.html)['"]\s*\)/m
}))
.pipe(babel())
.pipe(gulp.dest(libDir));
});
gulp.task('lib.styles', function() {
return processStyles(libDir);
});
gulp.task('dist.styles', function() {
return processStyles(distDir);
});