forked from EtherbitHQ/donut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
88 lines (78 loc) · 2.45 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
const gulp = require('gulp')
const browserify = require('browserify')
const source = require('vinyl-source-stream')
const sass = require('gulp-sass')
const cssnano = require('gulp-cssnano')
const rename = require('gulp-rename')
const config = {
jsx: {
source: './src/app/index.jsx',
watch: [ './src/app/**/*.js*' ],
destination: './app/',
name: 'app.js'
},
sass: {
source: './src/sass/style.scss',
watch: [ './src/sass/**/*.scss' ],
destination: './app/',
name: 'style.css'
},
resources: {
fonts: {
source: [ './bower_components/photon/fonts/*.woff', './bower_components/cryptocoins/fonts/*.woff' ],
destination: './app/fonts/'
},
icons: {
source: [ './src/icons/**/*.png' ],
destination: './app/icons/'
},
files: {
source: [ './src/package.json', './src/index.html', './src/main.js' ],
destination: './app/'
}
}
}
gulp.task('copy-icons', () => gulp.src(config.resources.icons.source).pipe(gulp.dest(config.resources.icons.destination)))
gulp.task('copy-fonts', () => gulp.src(config.resources.fonts.source).pipe(gulp.dest(config.resources.fonts.destination)))
gulp.task('copy-files', () => gulp.src(config.resources.files.source).pipe(gulp.dest(config.resources.files.destination)))
gulp.task('jsx', () => {
return browserify({
entries: config.jsx.source,
browserField: false,
builtins: false,
commondir: false,
insertGlobalVars: {
process: undefined,
global: undefined,
'Buffer.isBuffer': undefined,
Buffer: undefined
}
})
.transform('babelify')
.bundle()
.pipe(source(config.jsx.name))
.pipe(gulp.dest(config.jsx.destination))
})
gulp.task('jsx:build', [ 'jsx' ])
gulp.task('sass', () => {
return gulp
.src(config.sass.source)
.pipe(sass())
.pipe(rename(config.sass.name))
.pipe(gulp.dest(config.sass.destination))
})
gulp.task('sass:build', () => {
return gulp
.src(config.sass.source)
.pipe(sass())
.pipe(cssnano())
.pipe(rename(config.sass.name))
.pipe(gulp.dest(config.sass.destination))
})
gulp.task('jsx:watch', () => gulp.watch(config.jsx.watch, [ 'jsx' ]))
gulp.task('sass:watch', () => gulp.watch(config.sass.watch, [ 'sass' ]))
gulp.task('setup', [ 'copy-resources', 'build' ])
gulp.task('copy-resources', [ 'copy-fonts', 'copy-files', 'copy-icons' ])
gulp.task('watch', [ 'jsx:watch', 'sass:watch' ])
gulp.task('build', [ 'jsx:build', 'sass:build' ])
gulp.task('default', [ 'jsx', 'sass', 'watch' ])