-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
118 lines (100 loc) · 2.92 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
var envfile = require('envfile'),
fs = require('fs'),
gulp = require('gulp'),
sass = require('gulp-sass'),
concat = require('gulp-concat'),
nodemon = require('gulp-nodemon'),
watch = require('gulp-watch'),
image = require('gulp-image'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
babelify = require('babelify');
gulp.task('safe-styles', function() {
gulp.src([
'./node_modules/safe_ux_guidelines/scss/**/*.scss',
'./node_modules/npm-font-open-sans/open-sans.scss',
'!./node_modules/safe_ux_guidelines/scss/main.scss'
])
.pipe(gulp.dest('./static/scss'));
gulp.src('./static/scss/custom/main.scss')
.pipe(gulp.dest('./static/scss'));
});
gulp.task('image', function () {
gulp.src('./static/images/*')
.pipe(image())
.pipe(gulp.dest('./build/images'));
gulp.src('./favicon.ico')
.pipe(gulp.dest('./build'));
});
gulp.task('js-deps', function () {
gulp.src([
'./node_modules/jquery/dist/jquery.min.js',
'./node_modules/bootstrap/dist/js/bootstrap.min.js'
])
.pipe(concat('deps.js'))
.pipe(gulp.dest('./build/js'));
});
gulp.task('html', function () {
gulp.src(
'./index.html'
)
.pipe(gulp.dest('./build'));
});
gulp.task('scss', function () {
gulp.src([
'./static/scss/main.scss',
])
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./build/css'));
});
gulp.task('css-deps', function () {
gulp.src([
'./node_modules/bootstrap/dist/css/bootstrap.css'
])
.pipe(concat('deps.css'))
.pipe(gulp.dest('./build/css'));
});
gulp.task('fonts', function () {
gulp.src([
'./node_modules/bootstrap/fonts/*.*',
'./node_modules/npm-font-open-sans/fonts/**/*.*'
])
.pipe(gulp.dest('./build/fonts'));
});
gulp.task('js', function () {
var sourceDirectory = __dirname + '/static/js',
destinationDirectory = __dirname + '/build/js',
outputFile = 'client-scripts.js',
env = envfile.parseFileSync('.env');
var bundler = browserify(sourceDirectory + '/client-scripts.js').transform(babelify);
return bundler.bundle()
.on('error', function(err) {
console.log(err);
})
.pipe(source('client-scripts.js'))
.pipe(gulp.dest(destinationDirectory))
});
gulp.task('serve', function () {
var env = envfile.parseFileSync('.env');
nodemon({
script: './index.js',
ext: 'html js',
ignore: ['build/**/*.*', 'static/**/*.*', 'node_modules'],
tasks: [],
env: env
}).on('restart', function () {
console.log('server restarted....');
});
});
gulp.task('watch', function () {
watch(['./static/js/*.js', './static/js/**/*.js'], function () {
gulp.start('js');
});
watch('./static/css/*.css', function () {
gulp.start('css');
});
watch('./index.html', function () {
gulp.start('html');
});
});
gulp.task('default', ['js-deps', 'html', 'scss', 'css-deps', 'js', 'watch', 'serve', 'fonts', 'image']);