pifantastic / grunt-s3

A grunt task to automate moving files to/from Amazon S3.
MIT License
389 stars 81 forks source link

Per-file options seem to get ignored/overridden #50

Open nfriedly opened 11 years ago

nfriedly commented 11 years ago

I'm using this config:

s3: {
    options: {
        key: process.env.AWS_KEY,
        secret: process.env.AWS_SECRET,
        bucket: 'static.pagerank.nfriedly.com',
        access: 'public-read',
        maxOperations: 4,
        gzip: true,
        headers: {
            'Cache-Control': 'max-age=' + 60*60*24*365 // 1 year
        }
    },
    'prod': {
        // These options override the defaults
        options: {

        },
        // Files to be uploaded.
        upload: [{
            src: 'public/*.html',
            dest: '/',
            // do gzip (default)
            headers: {
                'Cache-Control': 'max-age=' + 60*1 // 1 minute
            }
        }, {
            src: 'public/*.{js,css}',
            dest: '/',
            // do gzip (default)
            // 1-year caching (default)
        }, {
            src: 'public/*.{jpg,png,gif}',
            dest: '/',
            gzip: false
            // 1-year caching(default)
        }]
    }
}

And everything uploads correctly, but all files have the default options: my .html files have a 1-year cache control header and my images are gzipped.

I know I can work around this with multiple sub-tasks, but I thought I'd let you know (and check if I'm doing anything wrong)

nfriedly commented 11 years ago

FWIW, this config gets the desired result.. it's just longer:

    s3: {
        options: {
            key: process.env.AWS_KEY,
            secret: process.env.AWS_SECRET,
            bucket: 'static.pagerank.nfriedly.com',
            access: 'public-read',
            maxOperations: 4,
            gzip: true,
            headers: {
                'Cache-Control': 'max-age=' + 60 * 60 * 24 * 365 // 1 year
            }
        },
        'prod-html': {
            options: {
                headers: {
                    'Cache-Control': 'max-age=' + 60 * 1 // 1 minute
                }
            },
            upload: [{
                src: 'public/*.html',
                dest: '/'
            }],
        },
        'prod-css-js': {
            upload: [{
                src: 'public/*.{js,css}',
                dest: '/'
            }]
        },
        'prod-images': {
            options: {
                gzip: false
            },
            upload: [{
                src: 'public/*.{jpg,png,gif}',
                dest: '/'
            }]
        }
    }
pifantastic commented 11 years ago

Definitely seems like a bug! I'll take a look. Thanks!

dmikey commented 11 years ago

Aaron I assume PR 62 fixes Issue 50? Can we close this Issue?