2016-08-22 18:02:02 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var gulp = require('gulp');
|
|
|
|
var plugins = require('gulp-load-plugins')();
|
|
|
|
var del = require('del');
|
|
|
|
|
2017-01-26 19:28:43 +00:00
|
|
|
var config = {
|
|
|
|
bowerDir: 'vendor/bower_components',
|
|
|
|
fontsDir: 'source/assets/fonts',
|
|
|
|
js: {
|
|
|
|
sourceDir: 'assets/js',
|
|
|
|
pattern: '/**/*.js',
|
|
|
|
outputDir: 'source/assets/js',
|
|
|
|
},
|
|
|
|
production: !!plugins.util.env.production,
|
|
|
|
sass: {
|
|
|
|
sourceDir: 'assets/sass',
|
|
|
|
pattern: '/**/*.sass',
|
|
|
|
outputDir: 'source/assets/css',
|
|
|
|
}
|
|
|
|
};
|
2016-12-13 23:57:59 +00:00
|
|
|
|
2017-04-30 10:53:30 +00:00
|
|
|
gulp.task('styles', function () {
|
2017-01-26 19:20:21 +00:00
|
|
|
return gulp.src([
|
2017-04-30 10:53:30 +00:00
|
|
|
config.bowerDir + '/font-awesome/css/font-awesome.css',
|
2017-04-30 11:57:10 +00:00
|
|
|
config.bowerDir + '/prism/themes/prism-twilight.css',
|
2017-04-30 10:53:30 +00:00
|
|
|
config.sass.sourceDir + config.sass.pattern
|
|
|
|
])
|
2016-08-22 18:02:02 +00:00
|
|
|
.pipe(plugins.plumber())
|
|
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
|
|
|
|
.pipe(plugins.sassGlob())
|
2017-01-07 22:37:12 +00:00
|
|
|
.pipe(plugins.sass())
|
2016-12-04 08:29:50 +00:00
|
|
|
.pipe(plugins.autoprefixer({
|
2017-01-26 19:28:43 +00:00
|
|
|
browsers: ["last 2 versions", "> 5%"],
|
2016-12-04 08:29:50 +00:00
|
|
|
cascade: false
|
|
|
|
}))
|
2017-01-26 19:20:21 +00:00
|
|
|
.pipe(plugins.concat('site.css'))
|
2017-03-18 22:51:05 +00:00
|
|
|
.pipe(plugins.if(config.production, plugins.purifycss([
|
2017-03-10 18:07:00 +00:00
|
|
|
'source/**/*.html',
|
|
|
|
'source/**/*.md',
|
|
|
|
'source/**/*.twig',
|
2017-03-10 18:06:39 +00:00
|
|
|
])))
|
2017-01-07 22:37:12 +00:00
|
|
|
.pipe(plugins.if(config.production, plugins.cleanCss()))
|
2016-08-22 18:02:02 +00:00
|
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
|
|
|
|
.pipe(plugins.if(!config.production, plugins.refresh()))
|
2017-01-26 19:28:43 +00:00
|
|
|
.pipe(gulp.dest(config.sass.outputDir));
|
2017-01-26 19:20:21 +00:00
|
|
|
});
|
2016-08-22 18:02:02 +00:00
|
|
|
|
2017-04-30 10:53:30 +00:00
|
|
|
gulp.task('scripts', function () {
|
2017-01-26 19:20:21 +00:00
|
|
|
return gulp.src([
|
2017-04-30 10:53:30 +00:00
|
|
|
config.bowerDir + '/jquery2/jquery.js',
|
|
|
|
config.bowerDir + '/bootstrap-sass/assets/javascripts/bootstrap.js',
|
|
|
|
config.bowerDir + '/prism/prism.js',
|
|
|
|
config.bowerDir + '/prism/components/prism-{apacheconf,bash,css,ini,json,nginx,php,sass,scss,sql,less,twig,xml,yaml}.js',
|
|
|
|
config.js.sourceDir + config.js.pattern
|
|
|
|
])
|
2016-08-22 18:02:02 +00:00
|
|
|
.pipe(plugins.plumber())
|
|
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
|
2017-01-26 19:20:21 +00:00
|
|
|
.pipe(plugins.concat('site.js'))
|
2016-08-22 18:02:02 +00:00
|
|
|
.pipe(plugins.if(config.production, plugins.uglify()))
|
|
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
|
2017-01-26 19:28:43 +00:00
|
|
|
.pipe(gulp.dest(config.js.outputDir));
|
2017-01-26 19:20:21 +00:00
|
|
|
});
|
2016-08-22 18:02:02 +00:00
|
|
|
|
2017-04-30 10:53:30 +00:00
|
|
|
gulp.task('fonts', function () {
|
2017-01-26 19:28:43 +00:00
|
|
|
return gulp.src(config.bowerDir + "/font-awesome/fonts/*")
|
|
|
|
.pipe(gulp.dest(config.fontsDir));
|
2017-01-26 19:20:21 +00:00
|
|
|
});
|
2016-08-22 18:02:02 +00:00
|
|
|
|
2017-04-30 10:53:30 +00:00
|
|
|
gulp.task('clean', function () {
|
2017-01-26 19:28:43 +00:00
|
|
|
del.sync(config.fontsDir);
|
|
|
|
del.sync(config.js.outputDir);
|
|
|
|
del.sync(config.sass.outputDir);
|
2017-03-16 08:15:03 +00:00
|
|
|
del.sync('output_*/assets/{css,fonts,js}');
|
2016-08-22 18:02:02 +00:00
|
|
|
});
|
|
|
|
|
2017-01-26 19:06:42 +00:00
|
|
|
gulp.task('default', ['clean', 'fonts', 'styles', 'scripts']);
|
2016-08-22 18:02:02 +00:00
|
|
|
|
2017-04-30 10:53:30 +00:00
|
|
|
gulp.task('watch', ['default'], function () {
|
2016-12-02 19:57:15 +00:00
|
|
|
plugins.refresh.listen();
|
2016-08-22 18:02:02 +00:00
|
|
|
|
2017-01-26 19:28:43 +00:00
|
|
|
gulp.watch(config.sass.sourceDir + config.sass.pattern, ['styles']);
|
|
|
|
gulp.watch(config.js.sourceDir + config.js.pattern, ['scripts']);
|
2016-12-02 19:57:15 +00:00
|
|
|
});
|