2015-01-05 15:01:42 +01:00
|
|
|
/*!
|
|
|
|
* 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'),
|
2015-02-08 22:37:55 +01:00
|
|
|
gettext = require('gulp-angular-gettext'),
|
2015-01-05 15:01:42 +01:00
|
|
|
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')));
|
|
|
|
});
|
|
|
|
|
2015-01-17 13:31:06 +01:00
|
|
|
// Catches all font files from all bower components.
|
|
|
|
gulp.task('fonts', function() {
|
2015-01-05 15:01:42 +01:00
|
|
|
return gulp.src(mainBowerFiles({
|
2015-01-17 13:31:06 +01:00
|
|
|
filter: /\.(eot)|(svg)|(ttf)|(woff)$/
|
2015-01-05 15:01:42 +01:00
|
|
|
}))
|
2015-01-17 13:31:06 +01:00
|
|
|
.pipe(gulp.dest(path.join(output_directory, 'fonts')));
|
2015-01-05 15:01:42 +01:00
|
|
|
});
|
|
|
|
|
2015-02-08 22:37:55 +01:00
|
|
|
// Extracts translatable strings using angular-gettext and saves them in file
|
|
|
|
// openslides/locale/angular-gettext/template-en.pot.
|
|
|
|
gulp.task('pot', function () {
|
|
|
|
return gulp.src(['openslides/*/static/templates/*/*.html',
|
|
|
|
'openslides/*/static/js/*/*.js'])
|
|
|
|
.pipe(gettext.extract('template-en.pot', {}))
|
|
|
|
.pipe(gulp.dest('openslides/locale/angular-gettext/'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// Compiles translation files (*.po) to *.json and saves them in the directory
|
|
|
|
// openslides/static/i18n/.
|
|
|
|
gulp.task('translations', function () {
|
|
|
|
return gulp.src('openslides/locale/angular-gettext/*.po')
|
|
|
|
.pipe(gettext.compile({
|
|
|
|
format: 'json'
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest(path.join(output_directory, 'i18n')));
|
|
|
|
});
|
|
|
|
|
2015-01-05 15:01:42 +01:00
|
|
|
// Gulp default task. Runs all other tasks before.
|
2015-01-17 13:31:06 +01:00
|
|
|
gulp.task('default', ['js', 'css', 'fonts'], function() {});
|