Created
January 4, 2015 10:42
-
-
Save alisamii/a3cd6809bc13686f8c29 to your computer and use it in GitHub Desktop.
Gulp setup
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
module.exports = function(gulp, options, $) { | |
gulp.task('clean:post', function () { | |
return del.sync([ | |
options.paths.app.build + '/**/*', | |
]); | |
}); | |
} |
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
module.exports = function(gulp, options, $) { | |
gulp.task('clean:pre', function () { | |
return del.sync([ | |
options.paths.app.build + '/**/*', | |
'!' + options.paths.app.build + '/.gitignore', | |
options.paths.public.assets + '/{js,css,fonts}/**/*' | |
]); | |
}); | |
} |
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
module.exports = function(gulp, options, $) { | |
gulp.task('css:pub', ['less:build'], function () { | |
return gulp.src(options.paths.app.build + '/css/**/*.css') | |
.pipe($.plumber()) | |
//.pipe($.autoprefixer()) | |
//.pipe($.minifyCss()) | |
// .pipe($.rename(function (path) { | |
// path.basename += ".min"; | |
// })) | |
.pipe(gulp.dest(options.paths.public.assets + '/css')) | |
.pipe($.filesize()) | |
.pipe($.livereload()) | |
.pipe($.notify("Css:pub finished")); | |
}); | |
} |
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
module.exports = function(gulp, options, $) { | |
gulp.task('fonts:pub', function () { | |
return gulp.src(options.paths.bower.fontAwesome + '/fonts/*-webfont.*') | |
.pipe($.plumber()) | |
.pipe(gulp.dest(options.paths.public.assets + '/fonts')); | |
}); | |
} |
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
////////////////////////////////////////////////// | |
// REQUIRE | |
////////////////////////////////////////////////// | |
var gulp = require('gulp'); | |
var $ = require('gulp-load-plugins')(); | |
var del = require('delete'); | |
////////////////////////////////////////////////// | |
// PATHS | |
////////////////////////////////////////////////// | |
var paths = { | |
app: { | |
assets: 'app/assets', | |
build: 'app/build' | |
}, | |
public: { | |
assets: 'public/assets' | |
}, | |
bower: { | |
jquery: 'bower_components/jquery', | |
respond: 'bower_components/respond', | |
html5shiv: 'bower_components/html5shiv', | |
bootstrap: 'bower_components/bootstrap', | |
fontAwesome: 'bower_components/font-awesome', | |
jqueryCookie: 'bower_components/jquery-cookie', | |
angular: 'bower_components/angular', | |
restangular: 'bower_components/restangular', | |
angular_ui: 'bower_components/angular-ui', | |
angular_ui_router: 'bower_components/angular-ui-router', | |
angular_round_progress: 'bower_components/angular-svg-round-progressbar', | |
angular_froala: 'bower_components/angular-froala', | |
froala: 'bower_components/froala-wysiwyg', | |
flow: 'bower_components/ng-flow', | |
angular_file_upload: 'bower_components/angular-file-upload', | |
lodash: 'bower_components/lodash/', | |
} | |
}; | |
////////////////////////////////////////////////// | |
// JS Tasks | |
////////////////////////////////////////////////// | |
require('./tasks/vendor')(gulp, {paths:paths}, $); | |
require('./tasks/js-app')(gulp, {paths:paths}, $); | |
require('./tasks/js-modules')(gulp, {paths:paths}, $); | |
require('./tasks/js-lib')(gulp, {paths:paths}, $); | |
require('./tasks/js-pub')(gulp, {paths:paths}, $); | |
////////////////////////////////////////////////// | |
// CSS Tasks | |
////////////////////////////////////////////////// | |
require('./tasks/less-build')(gulp, {paths:paths}, $); | |
require('./tasks/css')(gulp, {paths:paths}, $); | |
require('./tasks/fonts')(gulp, {paths:paths}, $); | |
////////////////////////////////////////////////// | |
// WATCH Tasks | |
////////////////////////////////////////////////// | |
require('./tasks/js-watch')(gulp, {paths:paths}, $); | |
require('./tasks/less-watch')(gulp, {paths:paths}, $); | |
////////////////////////////////////////////////// | |
// CLEAN Tasks | |
////////////////////////////////////////////////// | |
require('./tasks/clean-pre')(gulp, {paths:paths}, $); | |
require('./tasks/clean-post')(gulp, {paths:paths}, $); | |
////////////////////////////////////////////////// | |
// BUILD Tasks | |
////////////////////////////////////////////////// | |
gulp.task('build:dev', []); | |
gulp.task('build:prod', []); | |
// gulp clean:pre && gulp TASK && gulp clean:post | |
gulp.task('default', ['js:pub', 'js:lib', 'js:modules', 'css:pub', 'fonts:pub', 'js:watch', 'less:watch']); |
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
module.exports = function(gulp, options, $) { | |
gulp.task('js:app', function () { | |
return gulp.src([ | |
// Supporting specific order | |
options.paths.app.assets + '/js/app.js' | |
]) | |
.pipe($.plumber()) | |
.pipe($.concat('app.js')) | |
.pipe(gulp.dest(options.paths.app.build + '/js')) | |
.pipe($.jshint()) | |
.pipe($.jshint.reporter('default')); | |
}); | |
} |
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
module.exports = function(gulp, options, $) { | |
gulp.task('js:lib', function () { | |
return gulp.src([ | |
options.paths.app.assets + '/js/lib/*.js', | |
options.paths.bower.jquery + '/dist/*.min.*', | |
options.paths.bower.html5shiv + '/dist/html5shiv.min.js', | |
options.paths.bower.respond + '/dest/respond.min.js', | |
options.paths.bower.angular + '/*.js', | |
options.paths.bower.restangular + '/dist/*.js', | |
options.paths.bower.angular_ui + '/build/*.js', | |
options.paths.bower.angular_ui_router + '/release/*.js', | |
options.paths.bower.angular_round_progress + '/*.min.js', | |
options.paths.bower.angular_froala + '/src/*.js', | |
options.paths.bower.froala + '/js/*.min.js', | |
options.paths.bower.flow + '/dist/*.min.js', | |
options.paths.bower.angular_file_upload + '/*.min.{js,map}', | |
options.paths.bower.lodash + '/dist/lodash.min.js', | |
]) | |
.pipe($.plumber()) | |
.pipe(gulp.dest(options.paths.public.assets + '/js')); | |
}); | |
} |
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
module.exports = function(gulp, options, $) { | |
gulp.task('js:modules', function () { | |
return gulp.src([ | |
options.paths.app.assets + '/js/**/*.js' | |
]) | |
.pipe($.plumber()) | |
.pipe(gulp.dest(options.paths.public.assets + '/js/')); | |
}); | |
} |
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
module.exports = function(gulp, options, $) { | |
gulp.task('js:pub', ['js:vendor', 'js:app'], function () { | |
return gulp.src(options.paths.app.build + '/js/**/*.js') | |
.pipe($.plumber()) | |
.pipe($.uglify()) | |
.pipe($.rename(function (path) { | |
path.basename += ".min"; | |
})) | |
.pipe($.filesize()) | |
.pipe(gulp.dest(options.paths.public.assets + '/js')); | |
}); | |
} |
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
module.exports = function(gulp, options, $) { | |
gulp.task('js:watch', function () { | |
gulp.watch(options.paths.app.assets + '/js/**/*.js', ['js:pub', 'js:modules']); | |
}); | |
} |
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
module.exports = function(gulp, options, $) { | |
var onError = function (err) { | |
$.util.beep(); | |
console.log(err); | |
this.emit('end'); | |
}; | |
gulp.task('less:build', function () { | |
return gulp.src(options.paths.app.assets + '/less/{vendor,app}.less') | |
.pipe($.plumber(onError)) | |
.pipe($.lessSourcemap({ | |
generateSourceMap:true, | |
paths: [ | |
options.paths.bower.bootstrap + '/less', | |
options.paths.bower.fontAwesome + '/less', | |
options.paths.bower.froala + '/css/', | |
options.paths.app.assets + '/less' | |
] | |
})) | |
.pipe(gulp.dest(options.paths.app.build + '/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
module.exports = function(gulp, options, $) { | |
gulp.task('less:watch', function () { | |
gulp.watch(options.paths.app.assets + '/less/**/*.less', ['css:pub']); | |
}); | |
} |
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
module.exports = function(gulp, options, $) { | |
gulp.task('js:vendor', function () { | |
return gulp.src([ | |
// Specific order required by Bootstrap | |
options.paths.bower.bootstrap + '/js/transition.js', | |
options.paths.bower.bootstrap + '/js/alert.js', | |
options.paths.bower.bootstrap + '/js/button.js', | |
options.paths.bower.bootstrap + '/js/carousel.js', | |
options.paths.bower.bootstrap + '/js/collapse.js', | |
options.paths.bower.bootstrap + '/js/dropdown.js', | |
options.paths.bower.bootstrap + '/js/modal.js', | |
options.paths.bower.bootstrap + '/js/tooltip.js', | |
options.paths.bower.bootstrap + '/js/popover.js', | |
options.paths.bower.bootstrap + '/js/scrollspy.js', | |
options.paths.bower.bootstrap + '/js/tab.js', | |
options.paths.bower.bootstrap + '/js/affix.js', | |
options.paths.bower.jqueryCookie + '/jquery.cookie.js', | |
options.paths.app.assets + '/js/vendor.js' | |
]) | |
.pipe($.concat('vendor.js')) | |
.pipe(gulp.dest(options.paths.app.build + '/js')) | |
.pipe($.jshint()) | |
.pipe($.jshint.reporter('default')); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment