Search code examples
angularjsgruntjsgrunt-contrib-watch

How to serve angular app with grunt?


I am an angular newbie and trying to run grunt with angular. My grunt file looks like this, which plugin or module do I need to add to serve an angular app? I tried grunt-contrib-watch:

module.exports = function(grunt) {

    grunt.initConfig({

        pkg: grunt.file.readJSON('package.json'),
        sassFiles: 'app/**/*.scss',

        sass: {
            dist: {
                files: {
                    'build/site.css': 'app/site.scss'
                }
            }
        },

        watch: {
            sass: {
                tasks: ['sass'],
                files: 'app/**/*.scss'
            }

        },
        another: {
            files: ['app/*.js'],
            tasks: ['anothertask'],
            options: {
                // Start another live reload server on port 1337
                livereload: 1337
            }
        }
    });


    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-sass');


    grunt.registerTask('dev', ['default', 'watch','another']);
    grunt.registerTask('default', ['sass']);

};

Solution

  • grunt-contrib-watch run a task when files change (created,updated, etc..). To serve an angular app , try the plugin "grunt-serve".