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', () => {
|
2019-01-01 16:51:48 +00:00
|
|
|
return gulp.src('./app/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', () => {
|
2019-01-01 16:51:48 +00:00
|
|
|
return gulp.src('./app/js/**/*.js')
|
2018-11-10 00:57:18 +00:00
|
|
|
.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', () => {
|
2019-01-01 16:51:48 +00:00
|
|
|
return gulp.src('./app/fonts/**/*.ttf')
|
2018-11-10 00:57:18 +00:00
|
|
|
.pipe(gulp.dest('./dist/fonts'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// move images
|
|
|
|
// TODO: minimize
|
|
|
|
gulp.task('images', () => {
|
2019-01-01 16:51:48 +00:00
|
|
|
return gulp.src('./app/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', () => {
|
2019-01-01 16:51:48 +00:00
|
|
|
return gulp.src('./app/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', () => {
|
2019-01-01 16:51:48 +00:00
|
|
|
return gulp.src('./app/vendor/**/*.min.*')
|
2018-11-30 09:39:58 +00:00
|
|
|
.pipe(gulp.dest('./dist/vendor'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// move public files
|
|
|
|
gulp.task('public', () => {
|
2019-01-01 16:51:48 +00:00
|
|
|
return gulp.src('./app/*.*')
|
2018-11-30 09:39:58 +00:00
|
|
|
.pipe(gulp.dest('./dist'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// build index
|
|
|
|
gulp.task('index', () => {
|
2019-01-01 16:51:48 +00:00
|
|
|
return gulp.src(['./app/*.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'), () => {});
|