82 lines
2.8 KiB
JavaScript
82 lines
2.8 KiB
JavaScript
'use strict';
|
|
|
|
var gulp = require('gulp');
|
|
var plugins = require('gulp-load-plugins')();
|
|
var del = require('del');
|
|
|
|
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',
|
|
}
|
|
};
|
|
|
|
gulp.task('styles', function() {
|
|
return gulp.src([
|
|
config.bowerDir + '/font-awesome/css/font-awesome.css',
|
|
config.bowerDir + '/highlightjs/styles/default.css',
|
|
config.sass.sourceDir + config.sass.pattern
|
|
])
|
|
.pipe(plugins.plumber())
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
|
|
.pipe(plugins.sassGlob())
|
|
.pipe(plugins.sass())
|
|
.pipe(plugins.autoprefixer({
|
|
browsers: ["last 2 versions", "> 5%"],
|
|
cascade: false
|
|
}))
|
|
.pipe(plugins.concat('site.css'))
|
|
.pipe(plugins.if(!config.production, plugins.purifycss(['./source/*.html', './source/*.md', './source/*.twig', './ssource/*.html.twig'])))
|
|
.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));
|
|
});
|
|
|
|
gulp.task('scripts', function() {
|
|
return gulp.src([
|
|
config.bowerDir + '/jquery2/jquery.js',
|
|
config.bowerDir + '/bootstrap-sass/assets/javascripts/bootstrap.js',
|
|
config.bowerDir + '/highlightjs/highlight.pack.js',
|
|
config.js.sourceDir + config.js.pattern
|
|
])
|
|
.pipe(plugins.plumber())
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
|
|
.pipe(plugins.concat('site.js'))
|
|
.pipe(plugins.if(config.production, plugins.uglify()))
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
|
|
.pipe(gulp.dest(config.js.outputDir));
|
|
});
|
|
|
|
gulp.task('fonts', function() {
|
|
return gulp.src(config.bowerDir + "/font-awesome/fonts/*")
|
|
.pipe(gulp.dest(config.fontsDir));
|
|
});
|
|
|
|
gulp.task('clean', function() {
|
|
del.sync(config.fontsDir);
|
|
del.sync(config.js.outputDir);
|
|
del.sync(config.sass.outputDir);
|
|
del.sync('output_*/assets/css');
|
|
del.sync('output_*/assets/fonts');
|
|
del.sync('output_*/assets/js');
|
|
});
|
|
|
|
gulp.task('default', ['clean', 'fonts', 'styles', 'scripts']);
|
|
|
|
gulp.task('watch', ['default'], function() {
|
|
plugins.refresh.listen();
|
|
|
|
gulp.watch(config.sass.sourceDir + config.sass.pattern, ['styles']);
|
|
gulp.watch(config.js.sourceDir + config.js.pattern, ['scripts']);
|
|
});
|