forked from SoftwareBrothers/adminjs-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
61 lines (54 loc) · 1.87 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
const { spawn } = require('child_process')
const gulp = require('gulp')
const sass = require('gulp-sass')
const autoprefixer = require('gulp-autoprefixer')
const babel = require('gulp-babel')
const uglify = require('gulp-uglify')
const rename = require('gulp-rename')
const nodemon = require('gulp-nodemon')
const concat = require('gulp-concat')
const path = require('path')
gulp.task('sass', () => {
gulp.src('admin-bro/src/frontend/styles/**/*.sass')
.pipe(sass({
outputStyle: 'compressed',
}))
.pipe(autoprefixer())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('admin-bro/src/frontend/assets/styles'))
})
gulp.task('js', () => {
gulp.src(path.join('admin-bro/src/frontend/scripts/', '*.js'), { base: 'app' })
.pipe(concat('app.js'))
.pipe(babel({
presets: ['@babel/env'],
}))
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('admin-bro/src/frontend/assets/scripts'))
})
gulp.task('react', () => {
gulp.src(path.join('admin-bro/src/frontend/app.js'), { base: 'app' })
.pipe(concat('app.bundle.js'))
.pipe(babel({
presets: ['@babel/env', '@babel/react'],
}))
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('admin-bro/src/frontend/assets/scripts'))
})
gulp.task('debug', () => {
spawn('yarn', ['start'], { cwd: './', stdio: 'inherit' })
})
gulp.task('dbCreate', (done) => {
spawn('yarn', ['run', 'sequelize', 'db:create'], { cwd: 'admin-bro-example-app/', stdio: 'inherit' })
.on('close', () => {
spawn('yarn', ['run', 'sequelize', 'db:migrate'], { cwd: 'admin-bro-example-app/', stdio: 'inherit' })
.on('close', done)
});
});
gulp.task('watch', () => {
gulp.watch('admin-bro/src/frontend/styles/**/*.sass', ['sass'])
gulp.watch('admin-bro/src/frontend/scripts/**/*.js', ['js'])
})
gulp.task('default', ['dbCreate', 'sass', 'js', 'watch', 'debug'])