riot-starter/gulpfile.js

57 lines
1.5 KiB
JavaScript

'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', () => {
return gulp.src('./src/public/views/**/*.tag.html')
.pipe(concat('tags.js'))
.pipe(riot({compact: true, whitespace: false}))
.pipe(minify())
.pipe(gulp.dest('./dist/js'));
});
// combine javascript files
gulp.task('javascript', () => {
return gulp.src('./src/public/js/**/*.js')
.pipe(concat('combined.js'))
.pipe(minify())
.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/**/*')
.pipe(gulp.dest('./dist/img'));
});
// combine css
gulp.task('css', () => {
return gulp.src('css/*.css')
.pipe(concat('styles.css'))
.pipe(cssmin())
.pipe(gulp.dest('./dist/css'));
});
// build everything for production distribution
gulp.task('build', gulp.series('tags', 'javascript', 'css', 'fonts', 'images'), () => {
return gulp.src(['./src/public/index.html'])
.pipe(ref())
.pipe(gulp.dest('./dist'));
});
// create task
gulp.task('default', gulp.series('build'), () => {});