2018-11-10 00:57:18 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const gulp = require('gulp'),
|
|
|
|
riot = require('gulp-riot'),
|
|
|
|
concat = require('gulp-concat'),
|
|
|
|
minify = require('gulp-minify'),
|
|
|
|
cssmin = require('gulp-clean-css'),
|
|
|
|
ref = require('gulp-useref');
|
|
|
|
|
|
|
|
// build riotjs tags (components)
|
|
|
|
gulp.task('tags', () => {
|
2018-11-30 09:39:58 +00:00
|
|
|
return gulp.src('./src/public/tags/**/*.tag.html')
|
2018-11-10 00:57:18 +00:00
|
|
|
.pipe(concat('tags.js'))
|
|
|
|
.pipe(riot({compact: true, whitespace: false}))
|
2018-11-30 09:39:58 +00:00
|
|
|
.pipe(minify({ext: {min: '.min.js'}}))
|
2018-11-10 00:57:18 +00:00
|
|
|
.pipe(gulp.dest('./dist/js'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// combine javascript files
|
|
|
|
gulp.task('javascript', () => {
|
|
|
|
return gulp.src('./src/public/js/**/*.js')
|
|
|
|
.pipe(concat('combined.js'))
|
2018-11-30 09:39:58 +00:00
|
|
|
.pipe(minify({ext: {min: '.min.js'}}))
|
2018-11-10 00:57:18 +00:00
|
|
|
.pipe(gulp.dest('./dist/js'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// move fonts
|
|
|
|
gulp.task('fonts', () => {
|
|
|
|
return gulp.src('./src/public/fonts/**/*.ttf')
|
|
|
|
.pipe(gulp.dest('./dist/fonts'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// move images
|
|
|
|
// TODO: minimize
|
|
|
|
gulp.task('images', () => {
|
|
|
|
return gulp.src('./src/public/images/**/*')
|
2018-11-30 09:39:58 +00:00
|
|
|
.pipe(gulp.dest('./dist/images'));
|
2018-11-10 00:57:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// combine css
|
|
|
|
gulp.task('css', () => {
|
2018-11-30 09:39:58 +00:00
|
|
|
return gulp.src('./src/public/css/*.css')
|
2018-11-10 00:57:18 +00:00
|
|
|
.pipe(concat('styles.css'))
|
|
|
|
.pipe(cssmin())
|
|
|
|
.pipe(gulp.dest('./dist/css'));
|
|
|
|
});
|
|
|
|
|
2018-11-30 09:39:58 +00:00
|
|
|
// move vendor deps
|
|
|
|
gulp.task('vendor', () => {
|
|
|
|
return gulp.src('./src/public/vendor/**/*.min.*')
|
|
|
|
.pipe(gulp.dest('./dist/vendor'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// move public files
|
|
|
|
gulp.task('public', () => {
|
|
|
|
return gulp.src('./src/public/*.*')
|
|
|
|
.pipe(gulp.dest('./dist'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// build index
|
|
|
|
gulp.task('index', () => {
|
|
|
|
return gulp.src(['./src/public/*.html'])
|
2018-11-10 00:57:18 +00:00
|
|
|
.pipe(ref())
|
|
|
|
.pipe(gulp.dest('./dist'));
|
|
|
|
});
|
|
|
|
|
2018-11-30 09:39:58 +00:00
|
|
|
// build all assets
|
|
|
|
gulp.task('assets', gulp.parallel('css', 'fonts', 'images', 'javascript', 'vendor'), () => {});
|
|
|
|
|
|
|
|
// build everything for production distribution
|
|
|
|
gulp.task('build', gulp.series('assets', 'public', 'index', 'tags'), () => {});
|
|
|
|
|
2018-12-02 07:21:35 +00:00
|
|
|
// by default do this...
|
2018-11-10 00:57:18 +00:00
|
|
|
gulp.task('default', gulp.series('build'), () => {});
|