forked from jaflesch/totvsrs-frontend-challenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (50 loc) · 1.43 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
var gulp = require('gulp');
var babel = require('gulp-babel');
var concat = require('gulp-concat');
var browserSync = require("browser-sync").create();
var { logError } = require('gulp-sass');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var order = require("gulp-order");
function taskJS() {
return gulp.src('./assets/js/*/*.js')
.pipe(order([
"db/database.js",
"models/*.js",
"views/*.js",
"controllers/controllerInicial.js",
"controllers/controllerLogin.js",
"controllers/controllerRegistrar.js",
"controllers/controllerTodo.js",
"controllers/utils.js",
"controllers/controllersInit.js",
]))
.pipe(babel({presets: ['@babel/preset-env']}))
.pipe(concat('app.min.js'))
// .pipe(rename("app.min.js"))
.pipe(uglify())
.pipe(gulp.dest('./assets/js'))
.pipe(browserSync.stream())
}
//Compila scss em css
function style() {
//Local do scss
return gulp.src('./assets/scss/app.scss')
//Compilar Sass
.pipe(sass({outputStyle: 'compressed'}).on('error', sass,logError))
//Destino
.pipe(gulp.dest('./assets/css'))
.pipe(browserSync.stream());
}
//Watch for changes
function watch() {
browserSync.init({
server: {
baseDir: "./"
}
});
gulp.watch('./assets/scss/*.scss', style);
gulp.watch('./assets/js/*/*.js', taskJS);
}
exports.style = style;
exports.watch = watch;