adds a production, minified version
This commit is contained in:
103
gulpfile.js
103
gulpfile.js
@@ -18,30 +18,33 @@ var paths = {
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
})
|
||||
pipes.bowerFiles = function() {
|
||||
return gulp.src(mainBowerFiles({
|
||||
overrides : {
|
||||
jquery : {
|
||||
main: []
|
||||
},
|
||||
bootstrap : {
|
||||
main: [
|
||||
"dist/**/*.min.css",
|
||||
'./dist/fonts/*.*'
|
||||
]
|
||||
}
|
||||
}
|
||||
}),{base: 'webapp/bower_components'})
|
||||
.pipe(plugins.debug({title:'bower-file'}));
|
||||
}
|
||||
|
||||
var bowerFiles = mainBowerFiles({
|
||||
overrides : {
|
||||
jquery : {
|
||||
main: []
|
||||
},
|
||||
bootstrap : {
|
||||
main: [ "dist/**/*.css" ]
|
||||
}
|
||||
}
|
||||
})
|
||||
pipes.bowerFilesMinified = function() {
|
||||
return pipes.bowerFiles()
|
||||
.pipe(plugins.rename(function (path) {
|
||||
testpath = 'webapp/bower_components/' + path.dirname + '/' + path.basename + '.min' + path.extname;
|
||||
if (exists(testpath)) {
|
||||
path.extname = '.min' + path.extname;
|
||||
}
|
||||
}))
|
||||
.pipe(plugins.debug({title: 'bower-file-minimized:'}));
|
||||
}
|
||||
|
||||
pipes.validatedAppScripts = function() {
|
||||
return gulp.src(paths.appFiles)
|
||||
@@ -50,19 +53,25 @@ pipes.validatedAppScripts = function() {
|
||||
}
|
||||
|
||||
pipes.validatedIndex = function() {
|
||||
return gulp.src(paths.index);
|
||||
return gulp.src(paths.index)
|
||||
.pipe(plugins.htmlhint())
|
||||
.pipe(plugins.htmlhint.reporter());
|
||||
}
|
||||
|
||||
pipes.validatedPartials = function() {
|
||||
return gulp.src(paths.partials);
|
||||
return gulp.src(paths.partials)
|
||||
.pipe(plugins.htmlhint({'doctype-first': false}))
|
||||
.pipe(plugins.htmlhint.reporter());
|
||||
}
|
||||
|
||||
pipes.validatedPages = function() {
|
||||
return gulp.src(paths.pages)
|
||||
.pipe(plugins.htmlhint({'doctype-first': false}))
|
||||
.pipe(plugins.htmlhint.reporter());
|
||||
}
|
||||
|
||||
pipes.builtIndexDev = function() {
|
||||
var vendorFiles = gulp.src(bowerFilesMinified)
|
||||
var vendorFiles = pipes.bowerFilesMinified()
|
||||
.pipe(gulp.dest(paths.distDev + '/vendor'));
|
||||
var appScript = pipes.validatedAppScripts()
|
||||
.pipe(plugins.angularFilesort())
|
||||
@@ -84,6 +93,46 @@ pipes.builtIndexDev = function() {
|
||||
}
|
||||
|
||||
|
||||
pipes.builtIndexProd = function() {
|
||||
var filterJS = plugins.filter('**/*.js',{restore: true});
|
||||
var vendorFiles = pipes.bowerFiles()
|
||||
.pipe(filterJS)
|
||||
.pipe(plugins.debug({title:'non-minified-vendor:'}))
|
||||
.pipe(plugins.concat('vendor.min.js'))
|
||||
.pipe(plugins.uglify())
|
||||
.pipe(filterJS.restore)
|
||||
.pipe(gulp.dest(paths.distProd + '/vendor'));
|
||||
|
||||
|
||||
|
||||
var appScript = pipes.validatedAppScripts()
|
||||
.pipe(plugins.angularFilesort())
|
||||
.pipe(plugins.ngAnnotate())
|
||||
.pipe(plugins.concat('app.min.js'))
|
||||
.pipe(plugins.uglify())
|
||||
.pipe(gulp.dest(paths.distProd + '/js'));
|
||||
|
||||
var appStyle = gulp.src(paths.cssFiles)
|
||||
.pipe(plugins.minifyCss())
|
||||
.pipe(plugins.rename(function (path) {
|
||||
path.extname = '.min'+ path.extname;
|
||||
}))
|
||||
.pipe(gulp.dest(paths.distProd + '/css'))
|
||||
|
||||
var partials = pipes.validatedPartials()
|
||||
.pipe(gulp.dest(paths.distProd + '/js'))
|
||||
|
||||
var pages = pipes.validatedPages()
|
||||
.pipe(gulp.dest(paths.distProd + '/html'))
|
||||
|
||||
return pipes.validatedIndex()
|
||||
.pipe(plugins.inject(vendorFiles, {ignorePath: '/' + paths.distProd, name : 'bower'}))
|
||||
.pipe(plugins.inject(es.merge(appStyle,partials,pages), {ignorePath: '/' + paths.distProd}))
|
||||
.pipe(plugins.inject(appScript, {ignorePath: '/' + paths.distProd}))
|
||||
.pipe(gulp.dest(paths.distProd));
|
||||
|
||||
}
|
||||
|
||||
|
||||
gulp.task('test', function(done) {
|
||||
server = new karma.Server({
|
||||
@@ -99,3 +148,5 @@ gulp.task('test', function(done) {
|
||||
|
||||
|
||||
gulp.task('build-dev', pipes.builtIndexDev);
|
||||
|
||||
gulp.task('build-prod', pipes.builtIndexProd);
|
||||
|
||||
Reference in New Issue
Block a user