Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ==========================================
- Redstamp JS Frontend Gulp Workflow
- Version: 0.1
- Written By: Curtis Campbell
- Last Edied By: Curtis Campbell
- ==========================================
- */
- //Gulp Module Includes
- // ===================
- var gulp = require('gulp'),
- util = require('gulp-util');
- jshint = require('gulp-jshint');
- stylish = require('jshint-stylish');
- compass = require('gulp-compass');
- concat = require('gulp-concat');
- uglify = require('gulp-uglify');
- minifyCSS = require('gulp-minify-css');
- plumber = require('gulp-plumber');
- rename = require('gulp-rename');
- autoprefixer = require('gulp-autoprefixer');
- browserSync = require('browser-sync').create();
- // Configuration
- // =============
- var config = {
- PROJECT_NAME : 'clever',
- sassSourceDir : 'source/sass/**/*.scss',
- jsSourceDir : 'source/js/**/*.js',
- cssDir : 'public/css',
- jsDir : 'public/js',
- imgDir : 'public/images',
- viewsDir : 'public/views',
- imgSourceDir : 'source/img',
- production: !!util.env.production
- }
- // Display Successful Gulp Start Log
- // =================================
- gulp.task('default', ['compass', 'js'], function() {
- return util.log('Gulp ran successfully.')
- });
- // Compass Compile
- // ============
- gulp.task('compass', function() {
- return gulp.src([config.sassSourceDir])
- .pipe(compass({
- css: config.cssDir,
- sass: 'source/sass'
- }))
- .pipe(gulp.dest(config.cssDir))
- .pipe(browserSync.stream());
- });
- // Compile JavaScript
- // ==================
- gulp.task('js', function() {
- return gulp.src(config.jsSourceDir)
- .pipe(plumber({
- errorHandler: function (error) {
- console.log(error.message);
- this.emit('end');
- }}))
- .pipe(jshint())
- .pipe(jshint.reporter('jshint-stylish'))
- .pipe(concat(config.PROJECT_NAME + '.min.js'))
- .pipe(uglify())
- .pipe(gulp.dest(config.jsDir))
- .pipe(browserSync.stream())
- });
- // Browser Sync - Serve up assets to local server for page refresh etc
- // ===================================================================
- gulp.task('browser-sync', function() {
- browserSync.init({
- server: {
- baseDir: './public'
- }
- });
- gulp.watch(config.sassSourceDir, ['compass']);
- gulp.watch(config.jsSourceDir, ['js-watch']);
- gulp.watch('public/views/**/*.html').on('change', function() {
- browserSync.reload();
- });
- gulp.watch('public/index.html').on('change', function() {
- browserSync.reload();
- });
- });
- // Watch Tasks
- // ===========
- gulp.task('js-watch', ['js'], function() {
- browserSync.reload();
- });
- gulp.task('sass-watch', ['compass'], function() {
- browserSync.reload();
- });
- gulp.task('watch', ['browser-sync'], function() {
- return util.log('Watching for changes...');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement