0

I am using : https://github.com/gruntjs/grunt-contrib-connect

"grunt-contrib-connect": "^1.0.2",

After run: grunt connect

Running "connect:server" (connect) task
Started connect web server on http://localhost:8000

Done.

enter image description here

So when I check in my browser: localhost:8000 , does not open anything.

can someone help on this?

gruntfile pastenbin : http://pastebin.com/nL771d5j

Gruntfile.js

module.exports = function  (grunt) {
    var config = {};

    //setup the configuration object
    var jshint;

    //all tasks that must be loaded.
    var tasks = [
            ,'grunt-contrib-watch'
            ,'grunt-contrib-concat'
            ,'grunt-contrib-sass'
            ,'grunt-contrib-connect'
    ];

                //src ===============================
                var src;
                config.src = src = {
                     sassMain        : 'scss/main.scss',
                     distFolder      : 'public/stylesheets/dist.css',
                     devFolder       : 'public/stylesheets/dev.css',
                     sassFolder      : 'scss/**/*.scss',
                     serverPort: 9000,
                     serverHost: '0.0.0.0' 
                };


                //Concat ===============================

                var concat
                config.concat = concat = {};

                concat.dev = {
                    files: {
                        "public/myapp.development.js": [
                            "with-bootstrap/public/js/vendor"
                            ,"with-bootstrap/public/js/**/*.js"
                        ]
                    }
                };

                //Watch ===============================
                config.watch = {
                     scripts: {
                        files: ["<%= src.sassFolder %>"]
                        ,tasks: ["sass:dist"]
                     }
                }

                //Sass ===============================
                var sass;
                config.sass = sass = {};

                    //distribution
                        sass.dist = {
                            options: { 
                                style: "compressed",
                                noCache: true, 
                                sourcemap: 'none', 
                                update:true
                            }
                            , files: {
                                "<%= src.distFolder %>" : "<%= src.sassMain %>"
                            }
                        };

                    //development env.
                        sass.dev = {
                            options: { 
                                style: "expanded", 
                                lineNumber: true,
                            }
                            , files: {
                                "<%= src.devFolder %>" : "<%= src.sassMain %>"
                            }
                        };


                    //grunt serve ===============================
                    config.connect = {
                         server: {
                          options: {
                            port: 8000,
                            base: {
                              path: 'SITE',
                              options: {
                                index: 'index.html',
                                maxAge: 300000
                              }
                            }
                          }
                        }
                    };


    //Register custom tasks ===============================
    grunt.registerTask('default',['dev']);
    grunt.registerTask('dev', ['concat:dev','sass:dev']);
    grunt.registerTask('dist',['concat:dev','sass:dist']);



    //General setup ===============================
    grunt.initConfig(config);
    tasks.forEach(grunt.loadNpmTasks);

};
raduken
  • 2,091
  • 16
  • 67
  • 105

1 Answers1

0

If you're running the grunt-contrib-connect plugin by itself, you'll need the property keepalive set to true in your grunt config:

config.connect = {
    server: {
        options: {
            port: 8000,
            keepAlive: true,
            base: {
                path: 'SITE',
                options: {
                    index: 'index.html',
                    maxAge: 300000
                }
            }
        }   
    }
};

Worth Noting if you want to use your connect config as part of a chain of tasks, keepAlive will need to be set to false, otherwise tasks after connect task won't run. You can also keep connect running by pairing it with the watch task w/o using the keepAlive option.

theaccordance
  • 889
  • 5
  • 13