gulpfile.js
2.0 KB
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
94
95
96
97
98
99
var gulp = require('gulp');
var compass = require('gulp-compass');
var del = require('del');
var gulpFilter = require('gulp-filter');
// var webpack = require('webpack-stream');
// var webpackConfig = require('./tools/webpack.config.production.js');
var paths={
sass:['./src/scss/*.scss','./src/scss/**/*.scss']
};
gulp.task('compass', function() {
gulp.src(paths.sass)
.pipe(compass({
sourcemap:true,
css: './src/public/css',
sass: './src/scss',
image:'./src/public/img'
}))
.pipe(gulp.dest('./build/public/css'));
});
gulp.task('watch',function(){
gulp.watch(paths.sass,['compass']);
});
gulp.task('clean',function(){
return del([
'.tmp',
'build/*',
'!build/.git'
],{
force: true
});
});
gulp.task('copy',['clean'],function(){
var f=gulpFilter(['src/public','src/public/**/*','package.json','src/content','src/content/**/*']);
return gulp.src([
'./package.json',
'./src/**/*'
])
.pipe(f)
.pipe(gulp.dest('./build'));
});
/*copy vendor*/
gulp.task('copy-vendor',function(){
return gulp.src([
'./src/public/vendor.*.js'
])
.pipe(gulp.dest('./build/public'));
});
gulp.task('start',['copy'],function(done){
runBundle('npm start', done);
});
gulp.task('build',['copy'],function(){
return gulp.src(webpackConfig.entry.app)
.pipe(webpack(webpackConfig))
.pipe(gulp.dest('./build/public'));
});
gulp.task('deploy',['build'],function(done){
runBundle('node ./server/app.js', done);
});
function runBundle(cmd, done) {
var exec = require('child_process').exec;
var ls=exec(cmd, function(e, stdout) {
done();
});
ls.stdout.on('data', function (data) {
console.log(data);
});
ls.stderr.on('data', function (data) {
console.log(data);
});
ls.on('exit', function (code) {
console.log('child process exited with code ' + code);
});
ls.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err);
});
}