This repository has been archived on 2024-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
node-fftcg/gulpfile.js

70 lines
1.8 KiB
JavaScript
Raw Normal View History

var fs = require('fs');
var path = require('path');
var merge = require('merge-stream');
2018-09-30 18:21:59 +00:00
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
2018-09-30 20:23:16 +00:00
var coffee = require('gulp-coffee');
2018-10-02 00:57:06 +00:00
var sass = require('gulp-sass');
var pug = require('gulp-pug');
2018-09-30 20:23:16 +00:00
var insert = require('gulp-insert');
2018-09-30 18:21:59 +00:00
var uglify = require('gulp-uglify-es').default;
2018-09-30 20:23:16 +00:00
var concat = require('gulp-concat');
2018-09-30 18:21:59 +00:00
var paths = {
lib: 'client/lib/*.js',
coffee: 'client/scripts',
2018-10-02 00:57:06 +00:00
styles: 'client/style/*.scss',
pug: 'client/pug/*.pug',
dest: 'static',
maps: 'maps'
2018-09-30 18:21:59 +00:00
};
2018-09-30 20:50:48 +00:00
gulp.task('lib', function(){
return gulp.src(paths.lib)
.pipe(sourcemaps.init())
.pipe(concat('lib.min.js'))
2018-09-30 21:23:05 +00:00
.pipe(sourcemaps.write(paths.maps))
.pipe(gulp.dest(paths.dest))
2018-09-30 20:50:48 +00:00
});
function getFolders(dir) {
return fs.readdirSync(dir)
.filter(function(file) {
return fs.statSync(path.join(dir, file)).isDirectory();
});
}
gulp.task('coffee', function(){
var folders = getFolders(paths.coffee);
var tasks = folders.map(function(folder) {
return gulp.src(path.join(paths.coffee, folder, '/**/*.coffee'))
.pipe(sourcemaps.init())
.pipe(concat(folder + '.min.js'))
.pipe(coffee({bare: true}))
.pipe(insert.transform(function(contents, file) {
return '$(function () {' + contents + '});';
}))
.pipe(uglify())
.pipe(sourcemaps.write(paths.maps))
.pipe(gulp.dest(paths.dest))
});
return merge(tasks);
});
2018-10-02 00:57:06 +00:00
gulp.task('styles', function(){
return gulp.src(paths.styles)
.pipe(concat('style.css'))
.pipe(sass())
.pipe(gulp.dest(paths.dest))
});
gulp.task('pug', function(){
return gulp.src(paths.pug)
.pipe(pug())
.pipe(gulp.dest(paths.dest))
});
2018-10-02 00:57:06 +00:00
gulp.task('default', [ 'lib', 'coffee', 'styles', 'pug' ]);