-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
130 lines (98 loc) · 2.97 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
var webpack = require('webpack');
var gulp = require('gulp');
var gutil = require('gulp-util');
var path = require('path');
var webpackConfig = require('./webpack.config.js');
var less = require('gulp-less');
var cssmin = require('gulp-cssmin');
var sourcemaps = require('gulp-sourcemaps');
var rename = require('gulp-rename');
var webserver = require('gulp-webserver');
var copy = require('gulp-contrib-copy');
var ChildProcess = require('child_process');
gulp.task('server', function() {
gulp.src('build')
.pipe(webserver({
livereload: true,
directoryListing: false,
open: true
}));
});
gulp.task('default', function(callback) {
// Setup sourcemapping
webpackConfig.devtool = 'source-map';
lessBuild(false, function() {
gutil.log("Less", ': Built');
});
webpackBuild(function() {
gulp.watch([
'src/**/*.js',
'src/**/*.jsx'
], ["wepback:build"]);
gulp.watch([
'src/**/*.less'
], ["less:build"]);
callback();
});
gulp.src('src/index.html')
.pipe(copy())
.pipe(gulp.dest('build'))
gulp.src('src/libraries/*')
.pipe(copy())
.pipe(gulp.dest('build/libraries'))
gulp.src('src/fonts/*')
.pipe(copy())
.pipe(gulp.dest('build/fonts'))
gulp.src('src/icons/*')
.pipe(copy())
.pipe(gulp.dest('build/icons'))
});
gulp.task('wepback:build', function(callback) {
webpackBuild(callback);
});
gulp.task('less:build', function(callback) {
lessBuild(false, callback);
});
gulp.task('less:dist', function(callback) {
lessDist(false, callback);
});
gulp.task('docs', function(callback) {
documentationBuild(callback);
});
function webpackBuild(callback) {
webpack(webpackConfig, function(err, stats) {
gutil.log("Webpack", stats.toString({colors: true}));
callback();
});
}
function lessBuild(isProduction, callback) {
gulp.src(['src/index.less'])
.pipe(sourcemaps.init())
.pipe(less())
.pipe(rename("aptr-uikit.css"))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./build'));
callback();
}
function lessDist(isProduction, callback) {
gulp.src(['src/uiElements/index.less'])
.pipe(sourcemaps.init())
.pipe(less())
.pipe(rename("aptr-uikit.less"))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./dist/less'));
callback();
}
function documentationBuild(callback) {
var buildProcess = ChildProcess.exec("docco src/* src/**/* src/**/**/* src/**/**/**/*", {cwd: global.root}, function(error, stdout, stderr) {
if (error) {
console.log(error.stack);
console.log('Error code: '+error.code);
console.log('Signal received: '+error.signal);
}
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
buildProcess.kill();
callback();
});
}