Makes the dev file built more gulp-ish way
This commit is contained in:
91
gulpfile.js
91
gulpfile.js
@@ -1,6 +1,82 @@
|
||||
var gulp = require('gulp');
|
||||
var plugins = require('gulp-load-plugins')({});
|
||||
var karma = require('karma');
|
||||
var es = require('event-stream');
|
||||
var bowerFiles = 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'
|
||||
}
|
||||
|
||||
|
||||
pipes.vendorJsFiles = function() {
|
||||
return gulp.src(bowerFiles({
|
||||
overrides : {
|
||||
jquery : {
|
||||
main: []
|
||||
},
|
||||
bootstrap : {
|
||||
main: [ "dist/**/*.css" ]
|
||||
}
|
||||
}
|
||||
}).map(function(path, index,arr) {
|
||||
var newPath = path.replace(/.([^.]+)$/g, '.min.$1');
|
||||
console.log('path: ' + path + ' newpath:' + newPath + ' exits: ' + exists(newPath) )
|
||||
return exists ( newPath ) ? newPath : path;
|
||||
}))
|
||||
.pipe(plugins.debug({title: 'vendor-js:'}))
|
||||
}
|
||||
|
||||
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 = pipes.vendorJsFiles()
|
||||
.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({
|
||||
@@ -17,17 +93,4 @@ gulp.task('test', function(done) {
|
||||
|
||||
|
||||
|
||||
gulp.task('build', function() {
|
||||
return gulp.src('./webapp/html/index.html')
|
||||
.pipe(plugins.inject(
|
||||
gulp.src(['./webapp/js/**/*.js']).pipe(plugins.angularFilesort()),
|
||||
{
|
||||
ignorePath: '/webapp'
|
||||
}
|
||||
))
|
||||
.pipe(gulp.dest('./webapp'));
|
||||
});
|
||||
|
||||
gulp.task('autobuild', function() {
|
||||
return gulp.watch(['webapp/js/**/*.js','webapp/html/index.html'], ['build']);
|
||||
});
|
||||
gulp.task('build-dev', pipes.builtIndexDev);
|
||||
|
||||
Reference in New Issue
Block a user