Search code examples
javascriptnode.jsgruntjsgrunt-contrib-connect

grunt-localscreenshots is getting Not Found error on rendered pages from grunt-contrib-connect


I have a situation where I'm using grunt-contrib-connect to serve files to grunt-localscreenshots. The issue is that in the output from localscreenshots all of the images have the server error, "Not Found".

If I go to the server with the keepalive option I can navigate to any of the files in the directory.

The only detail I'm seeing that seems to be suggestive is that in the terminal output when connect is run "File: [no files]" is in the connect output.

Here's a stripped down version of my gruntfile that recreates the problem.

//start gruntfile
module.exports = function(grunt) {

// measures the time each task takes
require('time-grunt')(grunt);
var path = require('path'),
    argv = require('minimist')(process.argv.slice(2));

// load all grunt tasks
grunt.loadNpmTasks('grunt-localscreenshots');
grunt.loadNpmTasks('grunt-contrib-connect');


grunt.initConfig({

    localscreenshots: {
        options: {
            path: './release/screenshots',
            type: 'png',
            local: {
                path: './release',
                port: 8080
            },
            viewport: ['600x800', '768x1024', '1024x1024'],
        },
        src: ['release/*.html']
    },

    //task specific server
    connect: {
        server: {
            options: {
                port: 8080,
                base: ['./release/'],
                //keepalive: true,
                //open: true
            }
        }
    }
});

 grunt.registerTask('test', ['connect', 'localscreenshots']);
};

And my directory structure... Whoops, can't post images yet. Here's a link to the image.

https://drive.google.com/open?id=0B4bxMjEzI-oKTkM3YjNvT2lnZW8

Thanks in advance for any light anyone can shed on this.


Solution

  • And the simple answer is don't overthink your paths, I was specifying "./release" and such which was messing things up.