forked from mpaiva/material-resume
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
169 lines (148 loc) · 4.76 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// variables
var gulp = require('gulp');
var shell = require('gulp-shell');
var jade = require('gulp-jade');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
var gulpif = require('gulp-if');
var notify = require('gulp-notify');
var plumber = require('gulp-plumber');
var connect = require('gulp-connect');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var livereload = require('gulp-livereload');
var bowerFiles = require('main-bower-files');
// JSON containing the content for jade templates
var resumeFile = './_src/templates/content/mpaiva.json'
// get nodejs environment mod
// command to set environment > NODE_ENV=production gulp
var env = process.env.NODE_ENV || 'development';
// directories
var outputDir = 'builds/';
var materializeDir = 'bower_components/materialize/'
var jQueryDir = 'bower_components/jquery/dist/'
// tasks
// shell - Send terminal commands here
gulp.task('shell', shell.task([
'clear'
]));
// jade
gulp.task('jade', function() {
var resumeData = JSON.parse(fs.readFileSync(resumeFile));
// name your supporting jade blocks and includes
// with "_" to be ignored by the following expression:
// "_src/templates/**/!(_)*.jade"
return gulp.src('_src/templates/**/!(_)*.jade')
.pipe(plumber())
.pipe(
gulpif( env === 'development',
// if dev
jade( { pretty: true,
locals: resumeData } ),
// else
jade( { pretty: false,
locals: resumeData } )
))
.pipe(gulp.dest(outputDir + env))
.pipe(notify({
message: "<%= file.relative %> created successfuly",
templateOptions: {
date: new Date()
}
}))
.pipe(livereload())
});
// Bower Files Packaging
gulp.task('bowerFiles', function() {
return gulp.src(bowerFiles(), {
base: 'bower_components'
})
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(gulp.dest(outputDir + env + '/lib'))
.pipe(notify({
message: "<%= file.relative %> created successfuly",
templateOptions: {
date: new Date()
}
}))
.pipe(livereload());
});
// sass
gulp.task('sass', function() {
return gulp.src( '_src/sass/**/!(_)*.scss' )
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(
gulpif( env === 'development',
// if dev
sass({ sourceComments: 'map' }),
// else
sass()
)
)
// .pipe(gulpif(env === 'production', minifyCSS()))
.pipe(gulp.dest(outputDir + env + '/css/'))
.pipe(notify({
message: "<%= file.relative %> created successfuly",
templateOptions: {
date: new Date()
}
}))
.pipe(livereload())
});
// images
gulp.task('images', function() {
return gulp.src( '_src/assets/images/**/!(_)*.*' )
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(gulp.dest(outputDir + env + '/images/'))
.pipe(notify({
message: "<%= file.relative %> created successfuly",
templateOptions: {
date: new Date()
}
}))
.pipe(livereload())
});
// download folder
gulp.task('downloads', function() {
return gulp.src( '_src/assets/downloads/**/!(_)*.*' )
.pipe(plumber({errorHandler: notify.onError("Error: <%= error.message %>")}))
.pipe(gulp.dest(outputDir + env + '/downloads/'))
.pipe(notify({
message: "<%= file.relative %> created successfuly",
templateOptions: {
date: new Date()
}
}))
.pipe(livereload())
});
// Watch task
gulp.task('watch', function() {
var server = livereload();
gulp.watch( '_src/templates/**/*.json', ['jade']);
gulp.watch( '_src/templates/**/*.jade', ['jade']);
gulp.watch( '_src/sass/**/*.scss', ['sass']);
gulp.watch( 'bower_components/**/*.*', ['bowerFiles']);
gulp.watch( '_src/assets/images/**/!(_)*.*', ['images']);
gulp.watch( '_src/assets/downloads/**/!(_)*.*', ['downloads']);
});
// Git Automation -
gulp.task('git', shell.task([
'git status',
'git add .',
'git commit -m \'Gulp Git task detected changes.\'',
'git push origin'
]));
// Build Production
gulp.task('production', shell.task([
'NODE_ENV=production gulp'
]));
// Default tasks
gulp.task('default', ['shell', 'bowerFiles', 'sass', 'jade', 'images', 'downloads', 'watch']);
// end