102 lines
2.4 KiB
JavaScript
102 lines
2.4 KiB
JavaScript
var gulp = require('gulp');
|
|
var plugins = require('gulp-load-plugins')({});
|
|
var karma = require('karma');
|
|
var es = require('event-stream');
|
|
var mainBowerFiles = require('main-bower-files');
|
|
var exists = require('path-exists').sync
|
|
|
|
var pipes = {};
|
|
|
|
var paths = {
|
|
appFiles: 'webapp/js/**/*.js',
|
|
cssFiles: 'webapp/css/**/*.css',
|
|
partials: 'webapp/js/**/*.html',
|
|
pages : ['webapp/html/**/*.html', '!webapp/html/index.html'],
|
|
index : 'webapp/html/index.html',
|
|
distDev : 'dist/dev',
|
|
distProd: 'dist/prod'
|
|
}
|
|
|
|
|
|
var bowerFilesMinified = mainBowerFiles({
|
|
overrides : {
|
|
jquery : {
|
|
main: []
|
|
},
|
|
bootstrap : {
|
|
main: [ "dist/**/*.css" ]
|
|
}
|
|
}
|
|
}).map(function(path, index,arr) {
|
|
var newPath = path.replace(/.([^.]+)$/g, '.min.$1');
|
|
return exists ( newPath ) ? newPath : path;
|
|
})
|
|
|
|
var bowerFiles = mainBowerFiles({
|
|
overrides : {
|
|
jquery : {
|
|
main: []
|
|
},
|
|
bootstrap : {
|
|
main: [ "dist/**/*.css" ]
|
|
}
|
|
}
|
|
})
|
|
|
|
pipes.validatedAppScripts = function() {
|
|
return gulp.src(paths.appFiles)
|
|
.pipe(plugins.jshint())
|
|
.pipe(plugins.debug({title: 'validated-js:'}));
|
|
}
|
|
|
|
pipes.validatedIndex = function() {
|
|
return gulp.src(paths.index);
|
|
}
|
|
|
|
pipes.validatedPartials = function() {
|
|
return gulp.src(paths.partials);
|
|
}
|
|
|
|
pipes.validatedPages = function() {
|
|
return gulp.src(paths.pages)
|
|
}
|
|
|
|
pipes.builtIndexDev = function() {
|
|
var vendorFiles = gulp.src(bowerFilesMinified)
|
|
.pipe(gulp.dest(paths.distDev + '/vendor'));
|
|
var appScript = pipes.validatedAppScripts()
|
|
.pipe(plugins.angularFilesort())
|
|
.pipe(gulp.dest(paths.distDev + '/js'))
|
|
var appStyle = gulp.src(paths.cssFiles)
|
|
.pipe(gulp.dest(paths.distDev + '/css'))
|
|
|
|
var partials = pipes.validatedPartials()
|
|
.pipe(gulp.dest(paths.distDev + '/js'))
|
|
|
|
var pages = pipes.validatedPages()
|
|
.pipe(gulp.dest(paths.distDev + '/html'))
|
|
|
|
return pipes.validatedIndex()
|
|
.pipe(plugins.inject(vendorFiles, {ignorePath: '/'+ paths.distDev, name:'bower'}))
|
|
.pipe(plugins.inject(es.merge(appStyle,partials,pages), {ignorePath: '/'+ paths.distDev}))
|
|
.pipe(plugins.inject(appScript, {ignorePath: '/'+ paths.distDev}))
|
|
.pipe(gulp.dest(paths.distDev));
|
|
}
|
|
|
|
|
|
|
|
gulp.task('test', function(done) {
|
|
server = new karma.Server({
|
|
configFile: __dirname + '/test/karma.conf.js'
|
|
},function(exitCode) {
|
|
console.log('coucou');
|
|
done(exitCode);
|
|
console.log('coucou');
|
|
process.exit(exitCode);
|
|
});
|
|
server.start();
|
|
});
|
|
|
|
|
|
gulp.task('build-dev', pipes.builtIndexDev);
|