riot-starter/gulpfile.js

75 lines
2.0 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('./src/public/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('./src/public/js/**/*.js')
.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('./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/images'));
2018-11-10 00:57:18 +00:00
});
// combine css
gulp.task('css', () => {
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'));
});
// 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'));
});
// 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'), () => {});