OpenSlides/gulpfile.js

59 lines
1.7 KiB
JavaScript
Raw Normal View History

/*!
* Gulp tasks for development and production.
*
* Run
*
* $ ./node_modules/.bin/gulp
*
* for development and
*
* $ ./node_modules/.bin/gulp --production
*
* for production mode.
*/
var argv = require('yargs').argv,
gulp = require('gulp'),
concat = require('gulp-concat'),
gulpif = require('gulp-if'),
mainBowerFiles = require('main-bower-files'),
minifyCSS = require('gulp-minify-css'),
path = require('path'),
uglify = require('gulp-uglify');
// Directory where the results go
var output_directory = path.join('openslides', 'static');
// Catches all JavaScript files from all bower components and concats them to
// one file js/openslides-libs.js. In production mode the file is uglified.
gulp.task('js', function() {
return gulp.src(mainBowerFiles({
filter: /\.js$/
}))
.pipe(concat('openslides-libs.js'))
.pipe(gulpif(argv.production, uglify()))
.pipe(gulp.dest(path.join(output_directory, 'js')));
});
// Catches all CSS files from all bower components and concats them to one file
// css/openslides-libs.css. In production mode the file is uglified.
gulp.task('css', function() {
return gulp.src(mainBowerFiles({
filter: /\.css$/
}))
.pipe(concat('openslides-libs.css'))
.pipe(gulpif(argv.production, minifyCSS()))
.pipe(gulp.dest(path.join(output_directory, 'css')));
});
// Catches all PNG image files from all bower components.
gulp.task('img', function() {
return gulp.src(mainBowerFiles({
filter: /\.png$/
}))
.pipe(gulp.dest(path.join(output_directory, 'img')));
});
// Gulp default task. Runs all other tasks before.
gulp.task('default', ['js', 'css', 'img'], function() {});