Last active
November 17, 2016 23:26
-
-
Save noxify/8e3ff735a398f44851a2d5b3a8098eec to your computer and use it in GitHub Desktop.
simplified asset generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var uglify = require('gulp-uglify'); | |
var cleanCSS = require('gulp-clean-css'); | |
var pump = require('pump'); | |
var shell = require('gulp-shell'); | |
var Elixir = require('laravel-elixir'); | |
var del = require('del'); | |
var Task = Elixir.Task; | |
Elixir.extend('cleanup', function() { | |
new Task('cleanup', function() { | |
return del([ | |
'lib/**/*', | |
'dist/**/*' | |
]); | |
}); | |
}); | |
Elixir.extend('uglifier', function(src, dest, type) { | |
new Task('uglifier', function (cb) { | |
if ( type == "js") { | |
return pump([ | |
gulp.src(src + '/' + type + '/*.' + type), | |
uglify(), | |
gulp.dest(dest + '/' + type) | |
], | |
cb | |
); | |
} | |
if ( type == "css") { | |
return pump([ | |
gulp.src(src + '/' + type + '/*.' + type), | |
cleanCSS(), | |
gulp.dest(dest + '/' + type) | |
], | |
cb | |
); | |
} | |
return "unknown type"; | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var elixir = require('laravel-elixir'); | |
require('./elixir-extensions'); | |
elixir.config.production = true; | |
elixir.config.sourcemaps = false; | |
elixir(function (mix) { | |
var paths = { | |
'bower' : './bower_components/', | |
'assets' : './assets/', | |
'dest' : './lib/', | |
'dist' : './dist/' | |
}; | |
var scripts = { | |
"pace.js" : [ | |
paths.bower+'PACE/pace.js' | |
], | |
"vendor.js" : [ | |
paths.bower+'jquery/dist/jquery.js', | |
paths.bower+'bootstrap/dist/js/bootstrap.js', | |
paths.bower+'jquery-easing/jquery.easing.js' | |
], | |
}; | |
var styles = { | |
"pace.css" : [ | |
paths.bower+'PACE/themes/blue/pace-theme-center-circle.css' | |
], | |
}; | |
var copyJobs = [ | |
{ | |
"from" : paths.bower+"7-stroke-icons/pe-icon-7-stroke/fonts/**", | |
"to" : paths.dist+"fonts/" | |
}, | |
{ | |
"from" : paths.bower+"font-awesome/fonts/**", | |
"to" : paths.dist+"fonts/" | |
}, | |
{ | |
"from" : paths.bower+"ionicons/fonts/**", | |
"to" : paths.dist+"fonts/" | |
}, | |
{ | |
"from" : paths.bower+"simple-line-icons/fonts/**", | |
"to" : paths.dist+"fonts/" | |
}, | |
{ | |
"from" : paths.bower+"open-iconic/font/fonts/**", | |
"to" : paths.dist+"fonts/" | |
}, | |
{ | |
"from" : paths.bower+"bootstrap/dist/fonts/**", | |
"to" : paths.dist+"fonts/" | |
}, | |
]; | |
mix.cleanup(); | |
for( var index in copyJobs ) { | |
mix.copy(copyJobs[index]['from'], copyJobs[index]['to']); | |
} | |
for( var destStyle in styles ) { | |
mix.styles(styles[destStyle], paths.dest+'css/'+destStyle); | |
} | |
for( var destScript in scripts ) { | |
mix.styles(scripts[destScript], paths.dest+'js/'+destScript); | |
} | |
mix.uglifier(paths.dest, paths.dist, 'js'); | |
mix.uglifier(paths.dest, paths.dist, 'css'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "<name>", | |
"version": "1.0.0", | |
"description": "<desc>", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"license": "MIT", | |
"devDependencies": { | |
"gulp": "^3.9.1", | |
"gulp-clean-css": "^2.0.13", | |
"gulp-uglify": "^2.0.0", | |
"laravel-elixir": "^6.0.0-14", | |
"pump": "^1.0.1" | |
}, | |
"dependencies": { | |
"del": "^2.2.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment