-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
96 lines (94 loc) · 3.09 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
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
//gulp files should always be at the root of your code.
const gulp = require('gulp')
, sourcemaps = require('gulp-sourcemaps')
, scss = require('gulp-sass')
, CacheBuster = require('gulp-cachebust')
, cachebust = new CacheBuster()
, concat = require('gulp-concat')
, babel = require('gulp-babel')
, print = require('gulp-print')
, uglify = require('gulp-uglify')
, autoprefixer = require('gulp-autoprefixer')
, nodemon = require('nodemon');
// DECLARE FILE PATHS =============================
const basePath = './public';
const resetPath = "./public/styles/reset.css";
const paths = {
jsSrc: [`${basePath}/js/app.js`, `${basePath}/js/*.js`, `${basePath}/js/controllers/*.js`, `${basePath}/directives/*.js`, `${basePath}/js/services/*.js`],
scssSrc: [`${resetPath}`, `${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(babel({
presets: ['es2015']
}))
.pipe(concat('all.js'))
.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('build', ['js-bundle','scss-bundle']);
gulp.task('default', ['watch', 'js-bundle','scss-bundle', 'server']);
// gulp.task('hello', ()=> {
// console.log('Hello from inside your computer. We have gulp-off')
// })
//
//
// gulp.task('build-css', ()=> {
// return gulp.src('./styles/*')
// .pipe(sourcemaps.init())
// .pipe(sass())
// .pipe(cachebust.resources())
// .pipe(concat('styles.css'))
// .pipe(sourcemaps.write('./maps'))
// .pipe(gulp.dest('./dist'));
// })
//
// gulp.task('build-js', ()=> {
// return gulp.src('js/**/*.js')
// .pipe(sourcemaps.init())
// .pipe(print())
// .pipe(babel({ presets: ['es2015'] }))
// .pipe(concat('bundle.js'))
// //.pipe(uglify())
// .pipe(sourcemaps.write('./'))
// .pipe(gulp.dest('./dist/js'));
// });
//
// gulp.task('build', ['build-css', 'build-js'], ()=> {
// return gulp.src('./public/index.html')
// .pipe(cachebust.references())
// .pipe(gulp.dest('dist'));
// });
//
// gulp.task('styles', ()=> {
// gulp.src('./public/styles/**/*.scss')
// .pipe(sass().on('error', sass.logError))
// .pipe(gulp.dest('./css/'))
// });
//
// gulp.task('watch', ()=> {
// return gulp.watch(['./public/index.html','./public/views/*.html', './public/styles/*.*css', './public/js/**/*.js'], ['build']);
// });
//
// gulp.task('default', ['./public/index.html','./public/views/*.html', './public/styles/*.*css', './public/js/**/*.js'])