-
Notifications
You must be signed in to change notification settings - Fork 174
/
gulpfile.js
105 lines (91 loc) · 2.99 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
var $ = require('gulp-load-plugins')();
var gulp = require('gulp');
var autoprefixer = require('autoprefixer');
var rimraf = require('rimraf').sync;
var sequence = require('gulp4-run-sequence');
var supercollider = require('supercollider');
var sass = require('gulp-sass')(require('sass-embedded'));
var postcss = require('gulp-postcss');
var plumber = require('gulp-plumber');
var sourcemaps = require('gulp-sourcemaps');
var browser = require('browser-sync');
var port = process.env.SERVER_PORT || 3000;
supercollider
.config({
template: './docs/src/_template.hbs',
extension: 'md',
marked: false,
handlebars: require('./lib/handlebars')
})
.adapter('sass');
gulp.task('clean', function(done) {
rimraf('./_build');
rimraf('./docs/*.md');
done();
});
gulp.task('docs', function() {
return gulp.src('./docs/src/*.md')
.pipe(supercollider.init())
.pipe(gulp.dest('./docs'));
});
gulp.task('sass', function() {
return gulp.src('./motion-ui.scss')
.pipe(sourcemaps.init())
.pipe(plumber())
.pipe(sass().on('error', sass.logError))
// .pipe(postcss([autoprefixer()]))
.pipe(gulp.dest('./_build'));
});
gulp.task('javascript', function() {
return gulp.src('./motion-ui.js')
.pipe($.umd({
dependencies: function(file) {
return [{ name: 'jquery', amd: 'jquery', cjs: 'jquery', global: 'jQuery', param: '$' }];
},
exports: function(file) {
return 'MotionUI';
},
namespace: function(file) {
return 'MotionUI';
}
}))
.pipe(gulp.dest('./_build'));
});
gulp.task('dist:sass', gulp.series('sass', function() {
return gulp.src('./_build/motion-ui.css')
.pipe(gulp.dest('./dist'))
.pipe($.minifyCss())
.pipe($.rename('motion-ui.min.css'))
.pipe(gulp.dest('./dist'));
}));
gulp.task('dist:javascript', gulp.series('javascript', function() {
return gulp.src('./_build/motion-ui.js')
.pipe(gulp.dest('./dist'))
.pipe($.uglify())
.pipe($.rename('motion-ui.min.js'))
.pipe(gulp.dest('./dist'));
}));
gulp.task('dist', gulp.series('dist:sass', 'dist:javascript'));
gulp.task('build', function(done) {
sequence('clean', ['docs', 'sass', 'javascript'], done);
});
gulp.task('lint', function() {
return gulp.src('./src/**/*.scss')
.pipe($.scssLint());
})
function browserReloadSync(done) {
browser.reload();
done();
}
// Starts a BrowerSync instance
gulp.task('serve', gulp.series('build', function(done){
browser.init({server: './_build', port: port});
done();
}));
gulp.task('watch', function() {
gulp.watch(['./docs/src/*.md', './docs/src/_template.hbs'], gulp.series('docs', browserReloadSync));
gulp.watch(['./src/**/*.scss', './motion-ui.scss'], gulp.series('sass', browserReloadSync));
gulp.watch('./motion-ui.js', gulp.series('javascript', browserReloadSync));
});
gulp.task('default', gulp.series('build', 'serve', 'watch'));
// TODO: would be nice for serve and watch to display docs