-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
75 lines (65 loc) · 2.13 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
'use strict';
const gulp = require('gulp');
const connect = require('gulp-connect');
const htmlmin = require('gulp-htmlmin');
const sass = require('gulp-ruby-sass');
const autoprefixer = require('gulp-autoprefixer');
const babelify = require('babelify');
const concat = require('gulp-concat');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const reactify = require('reactify');
const replace = require('gulp-replace');
gulp.task('html', () => {
gulp.src('./app/*.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('./dist/www/'))
.pipe(connect.reload());
});
gulp.task('css', () => {
sass('./app/css/*.scss', {style: 'compressed'})
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(concat('main.css'))
.pipe(gulp.dest('./dist/www/css/'))
.pipe(connect.reload());
});
gulp.task('jsx', () => {
browserify('./app/jsx/Start.jsx', {debug: true})
.transform(babelify, {
presets: ['es2015', 'react']
}).bundle()
.pipe(source('index.js'))
.pipe(gulp.dest('./dist/www/js/'))
.pipe(connect.reload());
});
gulp.task('config', () => {
gulp.src('./app/config.xml')
.pipe(gulp.dest('./dist/'));
});
gulp.task('watch', () => {
gulp.watch('./app/*.html', ['html']);
gulp.watch('./app/css/*', ['css']);
gulp.watch('./app/jsx/**/*.jsx', ['jsx']);
gulp.watch('./app/config.xml', ['config']);
});
gulp.task('connect', () => {
connect.server({
root: './dist/www/',
livereload: true
});
});
gulp.task('prepare.test', () => {
gulp.src('./app/jsx/App.jsx')
.pipe(replace(/(\/\/ )?import\ Media/, 'import Media'))
.pipe(gulp.dest('./app/jsx/'));
});
gulp.task('prepare.build', () => {
gulp.src('./app/jsx/App.jsx')
.pipe(replace(/(\/\/ )?import\ Media/, '// import Media'))
.pipe(gulp.dest('./app/jsx/'));
});
gulp.task('default', ['prepare.test', 'html', 'css', 'jsx', 'watch', 'connect']);
gulp.task('build', ['prepare.build', 'html', 'css', 'jsx', 'config']);