Skip to content

Instantly share code, notes, and snippets.

@clouddueling
Created June 21, 2014 18:04
Show Gist options
  • Save clouddueling/a9282b3da946d3271914 to your computer and use it in GitHub Desktop.
Save clouddueling/a9282b3da946d3271914 to your computer and use it in GitHub Desktop.

Revisions

  1. clouddueling created this gist Jun 21, 2014.
    240 changes: 240 additions & 0 deletions gruntfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,240 @@
    module.exports = function(grunt) {

    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-recess');
    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-karma');
    grunt.loadNpmTasks('grunt-php');
    grunt.loadNpmTasks('grunt-phpunit');

    // Default Task
    grunt.registerTask('default', ['jshint', 'build', 'timestamp']);
    grunt.registerTask('build', ['clean', 'concat','recess:build', 'timestamp']);
    grunt.registerTask('release', ['clean', 'uglify', 'jshint', 'recess:min','shell:protractor', 'timestamp']);
    grunt.registerTask('test-watch', ['karma:watch']);

    // Print a timestamp (useful for when watching)
    grunt.registerTask('timestamp', function() {
    grunt.log.subhead(Date());
    });

    // Project configuration.
    grunt.initConfig({
    distdir: 'public/dist',
    pkg: grunt.file.readJSON('package.json'),
    banner: '/** \n' +
    ' * <%= pkg.name %>\n' +
    ' * Build: <%= grunt.template.today("yyyy-mm-dd h:mm:ss TT") %>\n' +
    ' * <%= pkg.homepage %>\n' +
    ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
    ' */\n\n',
    src: {
    js: ['public/apps/**/*.js', 'public/modules/**/*.js'],
    spec: ['public/tests/unit/**/*Spec.js'],
    lessWatch: 'public/less/**/*.less'
    },
    clean: ['<%= distdir %>/**/*'],
    shell: {
    options : {
    stdout: true
    },
    protractor: {
    command: 'protractor public/tests/e2e.conf.js'
    }
    },
    karma: {
    unit: {
    configFile: 'public/tests/unit.conf.js'
    },
    watch: {
    configFile: 'public/tests/unit.conf.js',
    singleRun: false,
    autoWatch: true
    }
    },
    recess: {
    options: {
    compile: true
    },
    build: {
    files: {
    '<%= distdir %>/css/main.css': ['public/less/main/main.less'],
    '<%= distdir %>/css/home.css': ['public/less/home/main.less']
    }
    },
    min: {
    files: {
    '<%= distdir %>/css/main.css': ['public/less/main/main.less'],
    '<%= distdir %>/css/home.css': ['public/less/home/main.less']
    }
    }
    },
    concat: {
    options: {
    banner: '<%= banner %>',
    process: function(src, filepath) {
    return '\n\n/*\n' + filepath + '\n*/\n' + src;
    }
    },
    vendor: {
    src: '<%= pkg.assets.vendor %>',
    dest: '<%= distdir %>/js/vendor.js'
    },
    profile: {
    src: '<%= pkg.assets.profile %>',
    dest: '<%= distdir %>/js/profile.js'
    },
    admin: {
    src: '<%= pkg.assets.admin %>',
    dest: '<%= distdir %>/js/admin.js'
    },
    rmc: {
    src: '<%= pkg.assets.rmc %>',
    dest: '<%= distdir %>/js/rmc.js'
    },
    lmc: {
    src: '<%= pkg.assets.lmc %>',
    dest: '<%= distdir %>/js/lmc.js'
    },
    broadcasts: {
    src: '<%= pkg.assets.broadcasters %>',
    dest: '<%= distdir %>/js/broadcasters.js'
    },
    promote: {
    src: '<%= pkg.assets.promote %>',
    dest: '<%= distdir %>/js/promote.js'
    },
    product: {
    src: '<%= pkg.assets.product %>',
    dest: '<%= distdir %>/js/product.js'
    },
    webpageBuilder: {
    src: '<%= pkg.assets.webpageBuilder %>',
    dest: '<%= distdir %>/js/webpageBuilder.js'
    }
    },
    uglify: {
    options: {
    banner: '<%= banner %>'
    },
    vendor: {
    src: '<%= pkg.assets.vendor %>',
    dest: '<%= distdir %>/js/vendor.js'
    },
    profile: {
    src: '<%= pkg.assets.profile %>',
    dest: '<%= distdir %>/js/profile.js'
    },
    admin: {
    src: '<%= pkg.assets.admin %>',
    dest: '<%= distdir %>/js/admin.js'
    },
    rmc: {
    src: '<%= pkg.assets.rmc %>',
    dest: '<%= distdir %>/js/rmc.js',
    options: {
    mangle: false
    }
    },
    lmc: {
    src: '<%= pkg.assets.lmc %>',
    dest: '<%= distdir %>/js/lmc.js'
    },
    broadcasts: {
    src: '<%= pkg.assets.broadcasters %>',
    dest: '<%= distdir %>/js/broadcasters.js'
    },
    promote: {
    src: '<%= pkg.assets.promote %>',
    dest: '<%= distdir %>/js/promote.js'
    },
    product: {
    src: '<%= pkg.assets.product %>',
    dest: '<%= distdir %>/js/product.js'
    },
    webpageBuilder: {
    src: '<%= pkg.assets.webpageBuilder %>',
    dest: '<%= distdir %>/js/webpageBuilder.js'
    }
    },
    phpunit: {
    classes: {
    dir: grunt.option('path') || ''
    },
    options: {
    bin: 'phpunit',
    colors: true,
    followOutput: true
    }
    },
    watch: {
    all: {
    files: ['public/apps/**/*.js', 'public/modules/**/*.js', 'public/tests/unit/**/*Spec.js', 'public/less/**/*.less'],
    tasks:['default','timestamp']
    },
    build: {
    files: ['public/apps/**/*.js', 'public/modules/**/*.js', 'public/tests/unit/**/*Spec.js', 'public/less/**/*.less'],
    tasks:['build','timestamp']
    },
    rmc: {
    files: ['public/apps/rmc/**/*.js'],
    tasks:['build','timestamp']
    },
    lmc: {
    files: ['public/apps/lmc/**/*.js'],
    tasks:['build','timestamp']
    },
    profile: {
    files: ['public/apps/profile/**/*.js'],
    tasks:['build','timestamp']
    },
    promote: {
    files: ['public/apps/promote/**/*.js'],
    tasks:['build','timestamp']
    },
    modules: {
    files: ['public/modules/**/*.js'],
    tasks:['build','timestamp']
    },
    broadcasters: {
    files: ['public/apps/broadcasters/**/*.js'],
    tasks:['build','timestamp']
    },
    webpageBuilder: {
    files: ['public/apps/webpageBuilder/**/*.js'],
    tasks:['build','timestamp']
    },
    less: {
    files: ['public/less/**/*.less', 'public/modules/**/*.less'],
    tasks: ['recess','timestamp']
    },
    js: {
    files: ['public/apps/**/*.js', 'public/modules/**/*.js'],
    tasks: ['concat','timestamp']
    },
    phpunit: {
    files: ['application/**/*.php'],
    tasks: ['phpunit']
    }
    },
    jshint:{
    options: {
    jshintrc: '/Users/tszemkus/.jshintrc',
    ignore: [
    'public/js/scripts.js',
    'public/modules/angular-bootstrap-colorpicker/js/bootstrap-colorpicker-module.js',
    'public/modules/fabric/fabric.js'
    ]
    },
    files: [
    '<%= src.spec %>',
    '<%= src.js %>',
    'gruntfile.js'
    ]
    }
    });
    };
    88 changes: 88 additions & 0 deletions gulpfile.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,88 @@
    var gulp = require('gulp'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    plumber = require('gulp-plumber')
    nodemon = require('gulp-nodemon');

    var clientDir = 'client';

    var publicDir = 'public';

    var bowerDir = 'public/bower_components';

    gulp.task('watch-account', function() {
    gulp.watch(clientDir + '/account/**/*.js', ['account-js']);
    gulp.watch(clientDir + '/account/**/*.html', ['account-html']);
    });

    gulp.task('default', [
    'account-js',
    'account-html',
    'account-vendor'
    ]);

    gulp.task('start', function() {
    nodemon({
    script: 'server.js',
    ext: 'html js',
    ignore: ['node_modules/']
    })
    .on('change', [])
    .on('restart', function() {
    console.log('Server restarted!');
    });
    });

    gulp.task('account-js', function() {
    return gulp.src(clientDir + '/account/**/*.js')
    .pipe(plumber())
    .pipe(concat('account.js'))
    .pipe(gulp.dest(publicDir + '/dist/account'));
    });

    gulp.task('account-html', function() {
    return gulp.src(clientDir + '/account/**/*.html')
    .pipe(plumber())
    .pipe(gulp.dest(publicDir + '/dist/account'));
    });

    gulp.task('account-vendor', function() {
    return gulp.src([
    bowerDir + '/lodash/dist/lodash.min.js',
    bowerDir + '/momentjs/min/moment.min.js',
    bowerDir + '/jquery/dist/jquery.min.js',
    bowerDir + '/bootstrap/dist/js/bootstrap.min.js',
    bowerDir + '/angular/angular.js',
    bowerDir + '/angular-animate/angular-animate.min.js',
    bowerDir + '/angular-bootstrap/ui-bootstrap-tpls.min.js',
    bowerDir + '/angular-ui-router/release/angular-ui-router.min.js',
    bowerDir + '/angular-loading-bar/build/loading-bar.min.js',
    bowerDir + '/angular-ui-calendar/src/calendar.js',
    bowerDir + '/seiyria-bootstrap-slider/dist/bootstrap-slider.min.js',
    bowerDir + '/jquery-steps/build/jquery.steps.min.js',
    bowerDir + '/toastr/toastr.min.js',
    bowerDir + '/bootstrap-file-input/bootstrap.file-input.js',
    bowerDir + '/jquery.slimscroll/jquery.slimscroll.min.js',
    bowerDir + '/holderjs/holder.js',
    bowerDir + '/raphael/raphael-min.js',
    bowerDir + '/morris.js/morris.js',
    bowerDir + '/scripts/vendors/responsive-tables.js',
    bowerDir + '/scripts/vendors/jquery.sparkline.min.js',
    bowerDir + '/flot/jquery.flot.js',
    bowerDir + '/flot/jquery.flot.resize.js',
    bowerDir + '/flot/jquery.flot.pie.js',
    bowerDir + '/flot/jquery.flot.stack.js',
    bowerDir + '/flot/jquery.flot.time.js',
    bowerDir + '/gauge.js/dist/gauge.min.js',
    bowerDir + '/jquery.easy-pie-chart/dist/angular.easypiechart.min.js',
    bowerDir + '/angular-wizard/dist/angular-wizard.min.js',
    bowerDir + '/fullcalendar/fullcalendar.min.js',
    bowerDir + '/fullcalendar/gcal.js',
    bowerDir + '/angularjs-imageupload-directive/public/javascripts/imageupload.js',
    '../../clouddueling/public/modules/time/time.js'
    ])
    .pipe(plumber())
    .pipe(concat('accountVendor.js'))
    .pipe(uglify())
    .pipe(gulp.dest(publicDir + '/dist/account'));
    });