Stairs/web/gulpfile.js

96 lines
2.1 KiB
JavaScript
Raw Normal View History

'use strict';
var gulp = require('gulp');
var ts = require('gulp-typescript');
var uglify = require('gulp-uglify');
var sass = require('gulp-sass');
var cleanCSS = require('gulp-clean-css');
var concat = require('gulp-concat');
var watch = require('gulp-debounced-watch');
var plumber = require('gulp-plumber');
var config =
{
dest: 'static/assets/dist/',
typescriptBase: 'static/assets/ts/',
sassBase: 'static/assets/sass/',
assets: ['static/assets/ts/**/*.html', 'static/assets/js/**/*.js']
};
config.typescriptSrc = config.typescriptBase + '**/*.ts';
config.sassSrc = config.sassBase + '**/*.scss';
gulp.task('default',
[
'compileTypescript',
'compileSass',
'copyAssets'
],
function(){});
gulp.task('watch',
[
'compileTypescript',
'compileSass',
'copyAssets'
],
function()
{
watch(config.typescriptSrc, function() { gulp.start('compileTypescript'); });
watch(config.sassSrc, function() { gulp.start('compileSass'); });
watch(config.assets, function() { gulp.start('copyAssets'); });
});
gulp.task('compileTypescript', function()
{
return gulp.src(config.typescriptSrc, { base: config.typescriptBase })
.pipe(plumber({
errorHandler: function (error)
{
console.log(error.message);
this.emit('end');
}}))
.pipe(ts(
{
noImplicitAny: true,
removeComments: true,
preserveConstEnums: true,
sourceMap: true,
module: 'amd'
}))
.pipe(uglify())
.pipe(gulp.dest(config.dest));
});
gulp.task('compileSass', function()
{
return gulp.src(config.sassSrc)
.pipe(plumber({
errorHandler: function (error)
{
console.log(error.message);
this.emit('end');
}}))
.pipe(sass())
.pipe(concat('bundle.css'))
.pipe(cleanCSS())
.pipe(gulp.dest(config.dest));
});
gulp.task('copyAssets', function()
{
return gulp.src(config.assets)
.pipe(plumber({
errorHandler: function (error)
{
console.log(error.message);
this.emit('end');
}}))
.pipe(gulp.dest(config.dest));
});