-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
executable file
·53 lines (44 loc) · 1.53 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
require('dotenv').load();
const gulp = require('gulp');
const babel = require('gulp-babel');
const webpack = require('gulp-webpack');
const nodemon = require('nodemon');
const dotenv = require('dotenv');
const WebpackConfig = require('./webpack.config');
const uglify = require('gulp-uglify');
const minifyCSS = require('gulp-minify-css');
gulp.task('css', function() {
console.log('Rebuilding CSS...');
gulp.src(['app/client/css/*.css'])
.pipe(minifyCSS())
.pipe(gulp.dest('app/client/dist'));
console.log('CSS built!')
});
gulp.task('js', function() {
console.log('Rebuilding JS...');
if (process.env.NODE_ENV === 'production') {
gulp.src(['app/client/components/*.vue', 'app/client/src/*.js'])
.pipe(webpack(WebpackConfig))
.pipe(uglify())
.pipe(gulp.dest('app/client/dist'))
} else {
gulp.src(['app/client/components/*.vue', 'app/client/src/*.js'])
.pipe(webpack(WebpackConfig))
.pipe(gulp.dest('app/client/dist'))
}
console.log('JS built!')
});
gulp.task('watch', ['js', 'css'], function() {
gulp.watch(['app/client/src/*.js', 'app/client/components/*.vue'], ['js']);
gulp.watch(['app/client/css/*.css'], ['css']);
});
// Restart server upon detecting change
gulp.task('default', ['watch'], function() {
nodemon({
script: 'app.js',
env: { 'NODE_ENV': process.env.NODE_ENV || 'DEV'},
watch: [
'app/server', 'app.js'
]
});
});