-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
54 lines (47 loc) · 1.5 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
const gulp = require('gulp');
const concat = require('gulp-concat');
const babel = require('gulp-babel');
const scss = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const nodemon = require('nodemon');
const sourcemaps = require('gulp-sourcemaps');
// File Paths ====================================
const basePath = './public/app';
const normalizePath = `${basePath}/styles/reset.css`;
const paths = {
jsSrc: [`${basePath}/app.js`, `${basePath}/**/**/*.js`],
scssSrc: [`${normalizePath}`, `${basePath}/styles/*.scss`],
server: './server/server.js'
};
// DEFINE TASKS ===================================
gulp.task('server', () => {
nodemon({
'script': paths.server
})
});
gulp.task('js-bundle', () => {
gulp.src(paths.jsSrc)
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015']
}))
.pipe(concat('all.js'))
.pipe(sourcemaps.write("./maps"))
.pipe(gulp.dest('./public/dist'));
});
gulp.task('scss-bundle', () => {
gulp.src(paths.scssSrc)
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(scss())
.pipe(concat('all.css'))
.pipe(gulp.dest('./public/dist'))
});
// WATCH TASK =======================================
gulp.task('watch', () => {
gulp.watch(paths.jsSrc, ['js-bundle']);
gulp.watch(paths.scssSrc, ['scss-bundle']);
});
gulp.task('default', ['watch', 'js-bundle','scss-bundle', 'server']);