-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
87 lines (76 loc) · 2.57 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
// based on https://omarfouad.com/
var gulp = require('gulp');
var gulpsync = require('gulp-sync')(gulp);
var notify = require('gulp-notify');
var connect = require('gulp-connect');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var babelify = require('babelify');
var sass = require('gulp-ruby-sass');
var bower = require('gulp-bower');
var config = {
sassPath: './src/sass',
jsPath: './src/js',
bowerDir: './bower_components',
publicPath: './public'
};
gulp.task('bower', function() {
return bower()
.pipe(gulp.dest(config.bowerDir))
});
gulp.task('connect', function() {
connect.server({
root: config.publicPath,
port: 4000
});
});
gulp.task('css', function() {
return sass(config.sassPath + '/**/*.scss', {
style: 'compressed',
loadPath: [
config.bowerDir + '/bootstrap-sass-official/assets/stylesheets',
config.sassPath
]})
.on("error", notify.onError(function (error) {
return "Error: " + error.message;
}))
.pipe(gulp.dest(config.publicPath + '/css'));
});
gulp.task('browserify', function() {
// grab the app.js file
return browserify(config.jsPath + '/app.js', {debug: true})
.transform('babelify', {
presets: ['es2015']
})
.bundle()
.pipe(source('app.js'))
// save it in the public/js/ directory
.pipe(gulp.dest(config.publicPath + '/js/'));
});
gulp.task('watch', function() {
gulp.watch('src/js/**/*.js', ['browserify']);
gulp.watch(config.sassPath + '/**/*.scss', ['css']);
});
gulp.task('copy-files', function() {
// copy javascript files
gulp.src([
config.bowerDir + '/jquery/dist/jquery.min.js',
config.bowerDir + '/handlebars/handlebars.min.js',
config.bowerDir + '/bootstrap-sass-official/assets/javascripts/bootstrap.min.js',
config.bowerDir + '/bootstrap-validator/dist/validator.min.js',
config.bowerDir + '/jquery-confirm2/dist/jquery-confirm.min.js'
])
.pipe(gulp.dest(config.publicPath + '/js/'));
// copy css
gulp.src([
config.bowerDir + '/jquery-confirm2/dist/jquery-confirm.min.css'
])
.pipe(gulp.dest(config.publicPath + '/css/'));
// copy fonts
gulp.src([
config.bowerDir + '/bootstrap-sass-official/assets/fonts/bootstrap/*'
])
.pipe(gulp.dest(config.publicPath + '/fonts/bootstrap/'));
});
gulp.task('init', gulpsync.sync(['bower', ['copy-files', 'browserify', 'css']]));
gulp.task('default', ['connect', 'watch']);