-
Notifications
You must be signed in to change notification settings - Fork 289
/
gulpfile.js
54 lines (44 loc) · 1.39 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
var gulp = require('gulp')
var less = require('gulp-less')
var react = require('gulp-react')
var minifyCss = require('gulp-minify-css')
var uglify = require('gulp-uglify')
var LessPluginAutoPrefix = require('less-plugin-autoprefix')
var DEST = './build'
gulp.task('jsxtranform', function(){
gulp.src('./src/**/*.jsx')
.pipe(react())
.pipe(uglify())
.pipe(gulp.dest(DEST))
})
gulp.task('less', function(){
gulp.src('./src/**/*.less')
.pipe(less({
plugins: [new LessPluginAutoPrefix({ browsers: ["last 2 versions"] })]
}))
.pipe(minifyCss())
.pipe(gulp.dest(DEST))
})
gulp.task('copy', function(){
// html
gulp.src(['./src/*.html'])
.pipe(gulp.dest(DEST))
// css
gulp.src(['./src/style/**/*.css',
'./node_modules/normalize.css/normalize.css'])
.pipe(minifyCss())
.pipe(gulp.dest(DEST + '/style/'))
gulp.src(['./src/**/*.+(ttf|woff|woff2)'])
.pipe(gulp.dest(DEST))
// js
gulp.src(['./src/script/**/*.js',
'./node_modules/react/dist/react.js',
'./node_modules/whatwg-fetch/fetch.js'])
.pipe(uglify())
.pipe(gulp.dest(DEST + '/script/'))
})
gulp.task('build', ['jsxtranform', 'less', 'copy'])
gulp.task('watch', ['build'], function(){
gulp.watch('./src/**/*', ['build'])
})
gulp.task('default', ['build'])