P3anuts
P3anuts

Reputation: 471

Migrate configuration to use grunt-contrib-connect 11.2 and livereload

I have an older project that was set up about a year ago using a yeoman generator. It has been working fine for livereload but now when I want to upgrade my node dependencies my current configuration does not work anymore. I have tried to find examples on how it should be but I cannot find any good examples.

Here is my current configuration, what do I need to change to get it working with the latest version of grunt-contrib-connect. The error message I get is:

Running "connect:livereload" (connect) task
Warning: connect.static is not a function Use --force to continue.

Also, do you have any tips on good tutorials to get a better understanding of how this all fits together?

connect: {
        options: {
            port: 9009,                
            hostname: 'localhost',
            livereload: 35729
        },
        proxies: [
            {
                context: '/api',
                host: 'localhost',
                port: 61215,
                https: false,
                xforward: false,
                rewrite: {
                    '^/api': '/app/api'
                }
            }
        ],
        livereload: {
            options: {
                open: false,
                base: [
                    '.tmp',
                    '<%= yeoman.app %>',
                ],
                middleware: function (connect, options) {

                    if (!Array.isArray(options.base)) {
                        options.base = [options.base];
                    }

                    var middlewares = [
                        connect.static('.tmp'),
                        connect().use(
                            '/modules',
                            connect.static('./modules')
                            ),
                            connect().use(
                            '/node_modules',
                            connect.static('./node_modules')
                            ),
                        connect.static(appConfig.app),
                        require('grunt-connect-proxy/lib/utils').proxyRequest
                    ];


                    // Make directory browse-able.
                    var directory = options.directory || options.base[options.base.length - 1];
                    middlewares.push(connect.directory(directory));

                    return middlewares;
                }
            }
        },

Upvotes: 1

Views: 346

Answers (1)

bobwal
bobwal

Reputation: 542

The new grunt-contrib-connect doesn't support connect.static. You'll need to install serve-static and use serveStatic instead of connect.static Warning: connect.static is not a function Use --force to continue

Upvotes: 1

Related Questions