2
0
Fork 0
es5-ff-spa-loader/gulpfile.js

79 lines
2 KiB
JavaScript
Raw Normal View History

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 jsdoc = require('gulp-jsdoc3');
2016-02-16 15:09:23 +00:00
var cssnano = require('gulp-cssnano');
2016-04-22 08:34:11 +00:00
var karma = require('karma');
var testServer = require('./test/test-server.js');
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';
gulp.task('clean', function() {
2016-02-16 15:09:23 +00:00
return gulp.src('dist').pipe(clean());
});
gulp.task('buildScript', ['test'], function() {
2016-02-16 15:09:23 +00:00
gulp.src(srcFile, {cwd: srcPath}).pipe(gulp.dest(distPathJS));
});
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-04-22 08:34:11 +00:00
gulp.task('testKarma',['clean'], function (done) {
testServer.start(function () {
new karma.Server({
configFile: __dirname + '/test/karma.conf.js',
singleRun: true
}, function(exitCode) {
console.log('Karma exit code:', exitCode);
//done();
testServer.stop(done);
}).start();
});
});
gulp.task('buildJSDoc', function (cb) {
var jsdocConfig = {
opts: {
destination: 'dist/jsdoc',
encoding: 'utf8',
access: 'all'
},
templates: {
cleverLinks: true
}
};
gulp.src(srcFile, {read: false}).pipe(jsdoc(jsdocConfig, cb));
});
2016-04-22 08:34:11 +00:00
gulp.task('test', ['clean','testKarma']);
2016-02-16 15:09:23 +00:00
gulp.task('build', ['test','buildCssMin','buildScriptMin'/*,'buildJSDoc'*/]);