2016-08-22 18:02:02 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var gulp = require('gulp');
|
|
|
|
var plugins = require('gulp-load-plugins')();
|
|
|
|
var del = require('del');
|
|
|
|
|
2016-12-30 00:57:25 +00:00
|
|
|
var config = require('./gulpfile.config')(plugins);
|
2016-12-13 23:57:59 +00:00
|
|
|
|
2016-08-22 18:02:02 +00:00
|
|
|
var app = {};
|
|
|
|
|
|
|
|
app.sass = function(paths, filename) {
|
|
|
|
return gulp.src(paths)
|
|
|
|
.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({
|
|
|
|
browsers: config.autoprefixer.browsers,
|
|
|
|
cascade: false
|
|
|
|
}))
|
2016-08-22 18:02:02 +00:00
|
|
|
.pipe(plugins.concat(filename))
|
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()))
|
2016-12-13 23:57:59 +00:00
|
|
|
.pipe(gulp.dest(config.sass.destination));
|
2016-08-23 01:44:39 +00:00
|
|
|
};
|
2016-08-22 18:02:02 +00:00
|
|
|
|
|
|
|
app.js = function(paths, filename) {
|
|
|
|
return gulp.src(paths)
|
|
|
|
.pipe(plugins.plumber())
|
|
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.init()))
|
|
|
|
.pipe(plugins.concat(filename))
|
|
|
|
.pipe(plugins.if(config.production, plugins.uglify()))
|
|
|
|
.pipe(plugins.if(!config.production, plugins.sourcemaps.write('.')))
|
2016-12-13 23:57:59 +00:00
|
|
|
.pipe(gulp.dest(config.js.destination));
|
2016-08-23 01:44:39 +00:00
|
|
|
};
|
2016-08-22 18:02:02 +00:00
|
|
|
|
|
|
|
app.copy = function(source, destination) {
|
|
|
|
return gulp.src(source)
|
|
|
|
.pipe(gulp.dest(destination));
|
2016-08-23 01:44:39 +00:00
|
|
|
};
|
2016-08-22 18:02:02 +00:00
|
|
|
|
|
|
|
gulp.task('clean', function() {
|
2016-12-13 23:57:59 +00:00
|
|
|
del.sync(config.fonts.destination);
|
|
|
|
del.sync(config.js.destination);
|
|
|
|
del.sync(config.sass.destination);
|
2016-08-22 18:02:02 +00:00
|
|
|
del.sync('output_*/assets/css');
|
|
|
|
del.sync('output_*/assets/fonts');
|
|
|
|
del.sync('output_*/assets/js');
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('fonts', function() {
|
2016-12-04 09:34:01 +00:00
|
|
|
return app.copy(
|
2016-12-13 23:57:59 +00:00
|
|
|
config.bower.path + "/font-awesome/fonts/*",
|
|
|
|
config.fonts.destination
|
2016-12-04 09:34:01 +00:00
|
|
|
);
|
2016-08-22 18:02:02 +00:00
|
|
|
});
|
|
|
|
|
2016-12-02 19:57:15 +00:00
|
|
|
gulp.task('styles', function() {
|
2016-08-22 18:02:02 +00:00
|
|
|
return app.sass([
|
2016-12-13 23:57:59 +00:00
|
|
|
config.bower.path + '/font-awesome/css/font-awesome.css',
|
2017-01-07 22:54:36 +00:00
|
|
|
config.bower.path + '/highlightjs/styles/default.css',
|
2016-12-13 23:57:59 +00:00
|
|
|
config.sass.source + config.sass.pattern
|
2016-08-22 18:02:02 +00:00
|
|
|
], 'site.css');
|
|
|
|
});
|
|
|
|
|
2016-12-02 19:57:15 +00:00
|
|
|
gulp.task('scripts', function() {
|
2016-08-22 18:02:02 +00:00
|
|
|
return app.js([
|
2016-12-13 23:57:59 +00:00
|
|
|
config.bower.path + '/jquery2/jquery.js',
|
|
|
|
config.bower.path + '/bootstrap-sass/assets/javascripts/bootstrap.js',
|
2017-01-07 22:54:36 +00:00
|
|
|
config.bower.path + '/highlightjs/highlight.pack.js',
|
2016-12-13 23:57:59 +00:00
|
|
|
config.js.source + config.js.pattern
|
2016-08-22 18:02:02 +00:00
|
|
|
], 'site.js');
|
|
|
|
});
|
|
|
|
|
2016-12-02 19:57:15 +00:00
|
|
|
gulp.task('build', ['clean', 'fonts', 'styles', 'scripts']);
|
2016-08-22 18:02:02 +00:00
|
|
|
|
2016-12-02 19:57:15 +00:00
|
|
|
gulp.task('default', ['build']);
|
2016-08-22 18:02:02 +00:00
|
|
|
|
2016-12-02 19:57:15 +00:00
|
|
|
gulp.task('watch', ['build'], function() {
|
|
|
|
plugins.refresh.listen();
|
2016-08-22 18:02:02 +00:00
|
|
|
|
2016-12-13 23:57:59 +00:00
|
|
|
gulp.watch(config.sass.source + config.sass.pattern, ['styles']);
|
|
|
|
gulp.watch(config.js.source + config.js.pattern, ['scripts']);
|
2016-12-02 19:57:15 +00:00
|
|
|
});
|