riot-starter/gulpfile.js

75 lines
1.9 KiB
JavaScript
Raw Normal View History

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', () => {
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}))
.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('./app/js/**/*.js')
2018-11-10 00:57:18 +00:00
.pipe(concat('combined.js'))
.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('./app/fonts/**/*.ttf')
2018-11-10 00:57:18 +00:00
.pipe(gulp.dest('./dist/fonts'));
});
// move images
// TODO: minimize
gulp.task('images', () => {
return gulp.src('./app/images/**/*')
.pipe(gulp.dest('./dist/images'));
2018-11-10 00:57:18 +00:00
});
// combine css
gulp.task('css', () => {
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'));
});
// move vendor deps
gulp.task('vendor', () => {
return gulp.src('./app/vendor/**/*.min.*')
.pipe(gulp.dest('./dist/vendor'));
});
// move public files
gulp.task('public', () => {
return gulp.src('./app/*.*')
.pipe(gulp.dest('./dist'));
});
// build index
gulp.task('index', () => {
return gulp.src(['./app/*.html'])
2018-11-10 00:57:18 +00:00
.pipe(ref())
.pipe(gulp.dest('./dist'));
});
// 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'), () => {});