/angularjs/

Prepare to Deploy a Web Project - AngularJS - Grunt. Part 1

2014-09-10 23:52:08

Everything you can find on GitHub

After checkout you have to run:

npm install
bower install

To prepare project please run:

grunt

Grunt will check if your js files are valid. Next will copy & uglify all javascript and copy them to public folder. And finally, copy & uglify all html files.

Grunt configuration (for now...)

'use strict';

module.exports = function (grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        jshint: {
            options: {
            },
            files: [
                'app/base/script/**/*.js',
                'app/components/script/*.js'
            ]
        },

        uglify: {
            development: {
                files: {
                    'public/base/base.min.js': ['app/base/script/*.js'],
                    'public/components/components.min.js': ['app/components/script/*.js']
                }
            },
            options: {
            }
        },

        htmlmin: {
            dev: {
                options: {
                    removeComments: true,
                    collapseWhitespace: true
                },
                files: [
                    {
                        expand: true,
                        cwd: 'app/base/view/',
                        dest: 'public/base/view/',
                        src: ['*.html'],
                        ext: '.html',
                        extDot: 'last'
                    },
                    {
                        expand: true,
                        cwd: 'app/components/view/',
                        dest: 'public/components/view/',
                        src: ['*.html'],
                        ext: '.html',
                        extDot: 'last'
                    }
                ]
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');

    grunt.registerTask('default', ['jshint', 'uglify', 'htmlmin']);
};