riot-starter/gulpfile.js

57 lines
1.5 KiB
JavaScript

'use strict';
var gulp = require('gulp');
var riot = require('gulp-riot');
var concat = require('gulp-concat');
var minify = require('gulp-minify');
var cssmin = require('gulp-cssmin');
var ref = require('gulp-useref');
// create task
gulp.task('default', ['build'], function () {});
// build riotjs tags (components)
gulp.task('tags', function () {
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', function () {
gulp.src('./src/public/js/**/*.js')
.pipe(concat('combined.js'))
// .pipe(minify())
.pipe(gulp.dest('./dist/js'))
});
// move fonts
gulp.task('fonts', function () {
gulp.src('./src/public/fonts/**/*.ttf')
.pipe(gulp.dest('./dist/fonts'))
});
// move images
// TODO: minimize
gulp.task('images', function () {
gulp.src('./src/public/images/**/*')
.pipe(gulp.dest('./dist/img'))
});
// combine css
gulp.task('css', function () {
gulp.src('css/*.css')
.pipe(concat('styles.css'))
.pipe(cssmin())
.pipe(gulp.dest('./dist/css'))
});
// build everything for production distribution
gulp.task('build', ['tags', 'javascript', 'css', 'fonts', 'images'], function () {
gulp.src(['./src/public/index.html'])
.pipe(ref())
.pipe(gulp.dest('./dist'))
});