2016-01-18 00:06:42 +00:00
|
|
|
|
|
|
|
var gulp = require('gulp');
|
|
|
|
var uglify = require('gulp-uglify');
|
|
|
|
var rename = require('gulp-rename');
|
|
|
|
var clean = require('gulp-clean');
|
|
|
|
var srcmaps = require('gulp-sourcemaps');
|
|
|
|
var mocha = require('gulp-mocha');
|
|
|
|
var jsdoc = require('gulp-jsdoc3');
|
2016-02-16 15:09:23 +00:00
|
|
|
var cssnano = require('gulp-cssnano');
|
2016-01-18 00:06:42 +00:00
|
|
|
|
2016-02-16 15:09:23 +00:00
|
|
|
var srcPath = './';
|
|
|
|
var srcFile = 'es5-ff-spa-loader.js';
|
|
|
|
var srcCss = 'es5-ff-spa-loader.css';
|
|
|
|
var distPathJS = 'dist/js';
|
|
|
|
var distPathCSS = 'dist/css';
|
|
|
|
var testSrc = 'test/*.js';
|
2016-01-18 00:06:42 +00:00
|
|
|
|
|
|
|
gulp.task('clean', function() {
|
2016-02-16 15:09:23 +00:00
|
|
|
return gulp.src('dist').pipe(clean());
|
2016-01-18 00:06:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('buildScript', ['test'], function() {
|
2016-02-16 15:09:23 +00:00
|
|
|
gulp.src(srcFile, {cwd: srcPath}).pipe(gulp.dest(distPathJS));
|
2016-01-18 00:06:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('buildScriptMin', ['buildScript'], function() {
|
|
|
|
gulp.src(srcFile, {cwd: srcPath})
|
|
|
|
.pipe(srcmaps.init())
|
|
|
|
.pipe(uglify({/*preserveComments: 'license'*/}))
|
|
|
|
.pipe(rename({ extname: '.min.js' }))
|
|
|
|
.pipe(srcmaps.write('.'))
|
2016-02-16 15:09:23 +00:00
|
|
|
.pipe(gulp.dest(distPathJS));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('buildCss', ['test'], function() {
|
|
|
|
gulp.src(srcCss, {cwd: srcPath}).pipe(gulp.dest(distPathCSS));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('buildCssMin',['buildCss'], function () {
|
|
|
|
return gulp.src(srcCss, {cwd: srcPath})
|
|
|
|
.pipe(srcmaps.init())
|
|
|
|
.pipe(cssnano())
|
|
|
|
.pipe(rename({ extname: '.min.css' }))
|
|
|
|
.pipe(srcmaps.write('.'))
|
|
|
|
.pipe(gulp.dest(distPathCSS));
|
2016-01-18 00:06:42 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('testMocha',['clean'], function() {
|
|
|
|
process.env.JUNIT_REPORT_PATH = 'test/data/report.xml';
|
|
|
|
return gulp.src(testSrc, {read: false}).pipe(mocha({reporter: 'mocha-jenkins-reporter'}));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('buildJSDoc', function (cb) {
|
|
|
|
var jsdocConfig = {
|
|
|
|
opts: {
|
2016-01-22 14:44:43 +00:00
|
|
|
destination: 'dist/jsdoc',
|
|
|
|
encoding: 'utf8',
|
|
|
|
access: 'all'
|
2016-01-18 00:06:42 +00:00
|
|
|
},
|
|
|
|
templates: {
|
2016-01-22 14:44:43 +00:00
|
|
|
cleverLinks: true
|
2016-01-18 00:06:42 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
gulp.src(srcFile, {read: false}).pipe(jsdoc(jsdocConfig, cb));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('test', ['clean','testMocha']);
|
2016-02-16 15:09:23 +00:00
|
|
|
gulp.task('build', ['test','buildCssMin','buildScriptMin'/*,'buildJSDoc'*/]);
|
2016-01-18 00:06:42 +00:00
|
|
|
|
|
|
|
|