-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
113 lines (103 loc) · 2.71 KB
/
Copy pathgulpfile.js
File metadata and controls
113 lines (103 loc) · 2.71 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
const gulp = require('gulp4');
const babel = require('gulp-babel');
const sass = require('gulp-sass');
const webpack = require('webpack-stream');
const nodemon = require('gulp-nodemon');
const webpackconfig = require('./webpack.config.js');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
gulp.task('bs:init', (done) => {
browserSync.init({
proxy: 'http://localhost:3090',
});
done();
});
gulp.task('copy', (done) => {
gulp.src([
'./public/**/*.*',
'./static/fonts/**/*.*',
'./index.html'], { base: '.', since: gulp.lastRun('copy') })
.pipe(gulp.dest('dist/'));
done();
});
gulp.task('sass', (done) => {
gulp.src(['./static/sass/**/*.scss'], { since: gulp.lastRun('sass') })
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('dist/static/css'));
done();
});
gulp.task('translate', (done) => {
gulp.src([
'./controllers/**/*.*',
'./db/**/*.*',
'./helpers/**/*.*',
'./models/**/*.*',
'./routes/**/*.*',
'./app.js',
'./config.js'], { base: '.', since: gulp.lastRun('translate') })
.pipe(babel({
presets: ['react', 'es2015', 'stage-1'],
}))
.pipe(gulp.dest('dist/'));
done();
});
gulp.task('startWebpack', (done) => {
gulp.src('./static/js/index.js')
.pipe(webpack(webpackconfig))
.pipe(gulp.dest('dist/'));
done();
});
gulp.task('start', (done) => {
let started = false;
nodemon({
script: 'dist/app.js',
})
.on('start', () => {
if (!started) {
done();
started = true;
}
})
.on('restart', () => {
setTimeout(() => {
reload({
stream: false,
});
}, 1000);
});
done();
});
gulp.task('reload', (done)=>{
reload({
stream: false,
});
done();
});
gulp.task('watch', (done) => {
//gulp.watch('dist/**/*.*').on('change', browserSync.reload);
gulp.watch([
'./static/sass/**/*.*'], gulp.series('sass'));
gulp.watch('./dist/static/css/*.*', gulp.series('reload'));
gulp.watch([
'./controllers/**/*.*',
'./db/**/*.*',
'./helpers/**/*.*',
'./models/**/*.*',
'./routes/**/*.*',
'./app.js',
'./config.js'], gulp.series('translate'));
gulp.watch([
'./public/**/*.*',
'./static/fonts/**/*.*',
'./index.html'], gulp.series('copy'));
done();
});
gulp.task('nodemon:start', gulp.series('start', 'bs:init', 'watch'), (done) => {
done();
});
gulp.task('default',
gulp.parallel('sass', 'translate', 'copy', 'startWebpack'),
(done) => {
done();
}
);