-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
64 lines (59 loc) · 2.27 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
var gulp = require('gulp')
var sass = require('gulp-sass')(require('node-sass'))
var rename = require('gulp-rename')
var uglify = require('gulp-uglify')
var browserify = require('browserify')
var babelify = require('babelify')
var source = require('vinyl-source-stream')
var buffer = require('vinyl-buffer')
var satellites = ['amalthea', 'callisto', 'ganymede', 'io']
var environment = process.env.NODE_ENV
gulp.task('styles', function () {
return gulp
.src([
'./web/core/styles/core.scss',
'./web/core/styles/errors.scss',
'./web/amalthea/styles/amalthea.scss',
'./web/callisto/styles/callisto.scss',
'./web/ganymede/styles/ganymede.scss',
'./web/io/styles/io.scss',
])
.pipe(
sass({
includePaths: [
'node_modules/foundation-sites/scss',
'node_modules/normalize.scss',
'web/core/styles',
'web'
],
outputStyle: environment == 'production' ? 'compressed' : 'nested'
}).on('error', sass.logError)
)
.pipe(gulp.dest('./web/public/css/'))
})
Array.prototype.forEach.call(satellites, function(satellite) {
if (environment == 'production') {
gulp.task(satellite, function() {
return browserify('./web/' + satellite + '/index.jsx')
.transform(babelify, {presets: ['@babel/preset-env', '@babel/react']})
.bundle()
.pipe(source('index.jsx'))
.pipe(buffer())
.pipe(rename(satellite + '.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./web/public/js/'))
})
} else {
gulp.task(satellite, function() {
return browserify('./web/' + satellite + '/index.jsx')
.transform(babelify, {presets: ['@babel/preset-env', '@babel/react']})
.bundle()
.pipe(source('index.jsx'))
.pipe(buffer())
.pipe(rename(satellite + '.min.js'))
.pipe(gulp.dest('./web/public/js/'))
})
}
})
gulp.task('scripts', gulp.series(satellites))
gulp.task('default', gulp.series('scripts', 'styles'))