Spirit/gulpfile.js

84 lines
2.6 KiB
JavaScript
Raw Normal View History

2015-09-06 06:27:02 +00:00
var gulp = require('gulp');
2015-10-05 01:53:13 +00:00
var gutil = require('gulp-util');
2015-09-06 06:27:02 +00:00
var sass = require('gulp-ruby-sass');
2015-10-05 01:53:13 +00:00
var coffee = require('gulp-coffee');
var sourcemaps = require('gulp-sourcemaps');
2015-10-05 03:34:15 +00:00
var Server = require('karma').Server;
2015-11-08 18:25:30 +00:00
var minifyCss = require('gulp-minify-css');
var rename = require("gulp-rename");
var concat = require('gulp-concat');
2015-11-08 21:09:20 +00:00
var uglify = require('gulp-uglify');
2015-11-09 00:41:05 +00:00
var gulpif = require('gulp-if');
2015-09-06 06:27:02 +00:00
var assetsPath = 'spirit/core/static/spirit/';
var cssPath = assetsPath + 'stylesheets/';
2015-10-05 01:53:13 +00:00
var jsPath = assetsPath + 'scripts/';
2015-09-06 06:27:02 +00:00
2015-11-08 18:25:30 +00:00
gulp.task('_sass', function () {
2015-10-05 01:53:13 +00:00
return sass(cssPath + 'src/styles.scss')
.on('error', sass.logError)
2015-11-09 00:41:05 +00:00
.pipe(gulp.dest(cssPath))
2015-10-05 01:53:13 +00:00
});
2015-11-09 04:57:33 +00:00
gulp.task('_css-minify', ['_sass'], function() {
2015-11-08 21:09:20 +00:00
var path = cssPath + 'vendors/';
2015-11-08 18:25:30 +00:00
return gulp.src([
2015-11-08 21:09:20 +00:00
path + '*.min.css',
2015-11-09 04:57:33 +00:00
cssPath + 'styles.css',
2015-11-08 18:25:30 +00:00
])
2015-11-09 04:57:33 +00:00
.pipe(minifyCss({compatibility: 'ie8', target: cssPath, relativeTo: cssPath}))
2015-11-08 18:25:30 +00:00
.pipe(concat('styles.all.min.css'))
2015-11-09 00:41:05 +00:00
.pipe(gulp.dest(cssPath))
2015-11-08 18:25:30 +00:00
});
2015-11-09 04:57:33 +00:00
gulp.task('css', ['_sass', '_css-minify']);
2015-11-08 18:25:30 +00:00
2015-11-09 00:41:05 +00:00
gulp.task('coffee', function() {
var pathVendors = jsPath + 'vendors/';
var pathCoffee = jsPath + 'src/';
var pathJs = jsPath + 'js/';
return gulp.src([
pathVendors + 'jquery.min.js',
pathVendors + 'atwho/jquery.caret.min.js',
pathVendors + 'atwho/jquery.atwho.min.js',
pathVendors + '**/*.js',
2015-11-12 15:15:42 +00:00
pathVendors + '**/*.coffee',
2015-11-09 00:41:05 +00:00
pathCoffee + 'util.coffee',
pathCoffee + 'tab.coffee',
pathCoffee + 'editor_file_upload.coffee',
2015-11-09 00:41:05 +00:00
pathCoffee + '*.coffee'
])
2015-10-05 01:53:13 +00:00
.pipe(sourcemaps.init())
.pipe(gulpif(/\.coffee$/, rename({suffix: ".no-min"})))
.pipe(gulpif(/\.coffee$/, coffee({bare: false}).on('error', gutil.log)))
.pipe(gulpif(/\.no-min\.js$/, gulp.dest(pathJs))) // JS Preview
.pipe(gulpif(/\.no-min\.js$/, uglify({mangle: false})))
2015-11-09 00:41:05 +00:00
.pipe(concat('all.min.js'))
2015-10-05 01:53:13 +00:00
.pipe(sourcemaps.write('.'))
2015-11-09 00:41:05 +00:00
.pipe(gulp.dest(jsPath))
2015-10-05 03:34:15 +00:00
});
2015-11-09 00:41:05 +00:00
gulp.task('_coffee-test', function() {
return gulp.src(jsPath + 'test/suites/*.coffee')
.pipe(sourcemaps.init())
.pipe(coffee({bare: false}).on('error', gutil.log))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(jsPath + 'test/suites/'))
2015-09-06 06:27:02 +00:00
});
2015-10-05 03:34:15 +00:00
gulp.task('_test', ['coffee', '_coffee-test'], function (done) {
new Server({
configFile: __dirname + '/' + jsPath + 'test/karma.conf.js',
singleRun: true
}, done).start();
});
gulp.task('test', ['coffee', '_coffee-test', '_test']);