-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
93 lines (77 loc) · 2.3 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
var path = require('path');
var settings = require('./settings');
var fs = require('fs');
var pump = require('pump');
var del = require('del');
var webpackConfig = require('./webpack.config');
var webpack = require('webpack');
var gulp = require('gulp');
var nodemon = require('gulp-nodemon');
var rename = require('gulp-rename');
var cleanCSS = require('gulp-clean-css');
var hash = require('gulp-hash');
var imagemin = require('gulp-imagemin');
var gulpWebpack = require('gulp-webpack');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
gulp.task('clean-build', function(){
return del(['build']);
});
gulp.task('build', ['build-static']);
gulp.task('build-static', ['hash']);
gulp.task('css', ['clean-build','bundle-css'],function (done) {
pump([
gulp.src('static/css/*.css'),
cleanCSS(),
gulp.dest('build/static/css')
], done);
});
gulp.task('bundle-css', function(done){
pump([
gulp.src(['static/css/*.css', '!static/css/bundle.css']),
concat('bundle.css'),
gulp.dest('static/css')
], done);
});
gulp.task('hash', ['css', 'images', 'js'], function (done) {
pump([
gulp.src('build/static/**/*'),
hash(),
gulp.dest('build/static'),
hash.manifest('manifest.json'),
gulp.dest('build/static')
], done);
});
gulp.task('images', ['clean-build'],function (done) {
pump([
gulp.src('static/images/*'),
imagemin(),
gulp.dest('build/static/images')
], done);
});
gulp.task('js', ['clean-build','webpack'], function (done) {
pump([
gulp.src('static/js/**/*.js'),
uglify(),
gulp.dest('build/static/js')
], done)
});
gulp.task('webpack', function(done){
pump([
gulp.src([]),
gulpWebpack(webpackConfig, webpack),
gulp.dest('static')
], done)
});
/**
* Development start task. Restarts upon changes to files.
*/
gulp.task('start', ['webpack', 'bundle-css'], function () {
var options = {
env: {'NODE_ENV': process.env.NODE_ENV},
ext: 'js json css', //the file extensions for which nodemon restarts upon changes
tasks: ['webpack', 'bundle-css'],
ignore: ['static/**/bundle.*'] //need to ignore changes to this as it is rebuilt every time nodemon restarts
};
nodemon(options);
});