2017-08-03 00:14:30 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var gulp = require('gulp');
|
|
|
|
var plugins = require('gulp-load-plugins')();
|
|
|
|
var config = require('./gulpfile.config')(plugins);
|
2017-08-18 21:23:07 +00:00
|
|
|
var del = require('del');
|
2017-08-03 00:14:30 +00:00
|
|
|
|
2017-08-18 21:23:07 +00:00
|
|
|
var app = {};
|
2017-08-03 00:14:30 +00:00
|
|
|
|
2017-08-18 21:23:07 +00:00
|
|
|
app.copy = function (sourceFiles, destination) {
|
|
|
|
return gulp.src(sourceFiles)
|
|
|
|
.pipe(gulp.dest(destination));
|
|
|
|
};
|
2017-08-03 00:14:30 +00:00
|
|
|
|
2017-08-18 21:23:07 +00:00
|
|
|
app.sass = function (sourceFiles, outputFile) {
|
|
|
|
return gulp.src(sourceFiles)
|
|
|
|
.pipe(plugins.plumber())
|
|
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
|
|
|
|
.pipe(plugins.sassGlob())
|
|
|
|
.pipe(plugins.sass())
|
|
|
|
.pipe(plugins.autoprefixer(config.sass.autoprefixer))
|
|
|
|
.pipe(plugins.concat(outputFile))
|
|
|
|
.pipe(plugins.if(config.production, plugins.purifycss(config.sass.purifyCss)))
|
|
|
|
.pipe(plugins.if(config.production, plugins.cleanCss()))
|
|
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
|
|
|
|
.pipe(plugins.if(!config.production, plugins.refresh()))
|
|
|
|
.pipe(gulp.dest(config.sass.outputDir));
|
|
|
|
};
|
|
|
|
|
|
|
|
app.js = function (sourceFiles, outputFile) {
|
|
|
|
return gulp.src(sourceFiles)
|
|
|
|
.pipe(plugins.plumber())
|
|
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
|
|
|
|
.pipe(plugins.concat(outputFile))
|
|
|
|
.pipe(plugins.if(config.production, plugins.uglify()))
|
|
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
|
|
|
|
.pipe(gulp.dest(config.js.outputDir));
|
|
|
|
};
|
|
|
|
|
|
|
|
gulp.task('clean', function () {
|
|
|
|
del.sync('source/assets/{css,fonts,js}');
|
|
|
|
del.sync('output_*/assets/{css,fonts,js}');
|
|
|
|
});
|
2017-08-03 00:14:30 +00:00
|
|
|
|
|
|
|
gulp.task('default', ['clean', 'fonts', 'styles', 'scripts']);
|
|
|
|
|
2017-08-18 21:23:07 +00:00
|
|
|
gulp.task('fonts', function () {
|
|
|
|
return app.copy('node_modules/font-awesome/fonts/*', config.fonts.outputDir);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('styles', function () {
|
2017-08-18 23:28:44 +00:00
|
|
|
app.sass([
|
2017-08-03 00:39:46 +00:00
|
|
|
'node_modules/font-awesome/css/font-awesome.css',
|
|
|
|
config.sass.sourceDir + '/main.sass'
|
2017-08-18 23:28:44 +00:00
|
|
|
], 'main.css');
|
|
|
|
|
|
|
|
app.sass([
|
|
|
|
'node_modules/prismjs/themes/prism-twilight.css',
|
|
|
|
config.sass.sourceDir + '/post.sass'
|
|
|
|
], 'post.css')
|
|
|
|
|
|
|
|
app.sass(config.sass.sourceDir + '/about.sass', 'about.css');
|
|
|
|
app.sass(config.sass.sourceDir + '/blog.sass', 'blog.css');
|
|
|
|
app.sass(config.sass.sourceDir + '/experience.sass', 'experience.css');
|
|
|
|
app.sass(config.sass.sourceDir + '/project.sass', 'project.css');
|
|
|
|
app.sass(config.sass.sourceDir + '/talk.sass', 'talk.css');
|
|
|
|
app.sass(config.sass.sourceDir + '/testimonials.sass', 'testimonials.css');
|
2017-08-18 21:23:07 +00:00
|
|
|
});
|
2017-08-03 00:39:46 +00:00
|
|
|
|
2017-08-18 21:23:07 +00:00
|
|
|
gulp.task('scripts', function () {
|
2017-08-18 23:38:46 +00:00
|
|
|
app.js([
|
|
|
|
'node_modules/jquery/dist/jquery.js',
|
|
|
|
config.js.sourceDir + '/**/*.js'
|
|
|
|
], 'main.js')
|
|
|
|
|
2017-08-18 23:28:44 +00:00
|
|
|
app.js([
|
2017-08-03 00:39:46 +00:00
|
|
|
'node_modules/jquery/dist/jquery.js',
|
|
|
|
'node_modules/prismjs/prism.js',
|
2017-08-06 18:01:22 +00:00
|
|
|
'node_modules/prismjs/components/prism-{apacheconf,bsash,css,diff,ini,json,nginx,php,sass,scss,sql,less,twig,xml,yaml}.js',
|
2017-08-18 23:38:46 +00:00
|
|
|
], 'post.js')
|
2017-08-18 21:23:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('watch', ['default'], function () {
|
|
|
|
plugins.refresh.listen();
|
2017-08-03 00:14:30 +00:00
|
|
|
|
2017-08-18 21:23:07 +00:00
|
|
|
gulp.watch(config.sass.sourceDir + config.sass.pattern, ['styles']);
|
|
|
|
gulp.watch(config.js.sourceDir + config.js.pattern, ['scripts']);
|
|
|
|
});
|