-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
111 lines (101 loc) · 2.85 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
'use strict';
const path = require('path');
const gulp = require('gulp');
const gutil = require('gulp-util');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const rimraf = require('gulp-rimraf');
const header = require('gulp-header');
const less = require('gulp-less');
const csso = require('gulp-csso');
const sourcemaps = require('gulp-sourcemaps');
const autoprefixer = require('gulp-autoprefixer');
const webpack = require('webpack');
const pkg = require('./package.json');
gulp.task('build.js.clean', () => {
return gulp.src(['dist', 'docs/lib', 'docs/js', 'docs/css'], { read: false })
.pipe(rimraf());
});
gulp.task('build.js', ['build.js.clean'], (done) => {
webpack(require('./webpack.config.js'), function(err, stats) {
if( err ) throw new gutil.PluginError('webpack', err);
gutil.log('[webpack]', stats.toString({
colors: true,
children: true,
chunks: true,
modules: false
}));
done();
});
});
gulp.task('build.js.min', ['build.js'], (done) => {
return gulp.src(path.join('dist/x-workbench.js'))
.pipe(header([
'/*!',
'* <%= pkg.name %>',
'* <%= pkg.homepage %>',
'*',
'* Copyright attrs and others',
'* Released under the <%=pkg.license%> license',
'* https://github.com./<%=pkg.repository%>/blob/master/LICENSE',
'*/',
''
].join('\n'), { pkg: pkg }))
.pipe(gulp.dest('dist'))
.pipe(uglify())
.pipe(header('/*! <%= pkg.name %> - attrs */', { pkg: pkg }))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist'));
});
gulp.task('build.less', ['build.js.min'], () => {
return gulp.src(path.join('lib/less/index.less'))
.pipe(less({
paths: ['lib/less']
}))
.pipe(autoprefixer())
.pipe(rename({
basename: 'x-workbench'
}))
.pipe(gulp.dest('dist'))
.pipe(csso())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('dist'));
});
gulp.task('build.docs.js', ['build.less'], (done) => {
webpack(require('./webpack.config.docs.js'), function(err, stats) {
if( err ) throw new gutil.PluginError('webpack', err);
gutil.log('[webpack]', stats.toString({
colors: true,
children: true,
chunks: true,
modules: false
}));
done();
});
});
gulp.task('build.docs.less', ['build.docs.js'], () => {
return gulp.src(path.join('docs/less/index.less'))
.pipe(less({
paths: ['docs']
}))
.pipe(autoprefixer())
.pipe(gulp.dest('docs/css'))
.pipe(csso())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest('docs/css'));
});
gulp.task('build.docs', ['build.docs.less'], () => {
return gulp.src('dist/*')
.pipe(gulp.dest('docs/lib'));
});
gulp.task('build', ['build.less']);
gulp.task('docs', ['build.docs']);
// conclusion
gulp.task('watch', ['build.watch']);
gulp.task('default', ['docs']);