Created
August 22, 2013 08:14
-
-
Save MathieuLoutre/6304468 to your computer and use it in GitHub Desktop.
Compress + AWS S3 upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grunt.initConfig({ | |
aws: grunt.file.readJSON('aws-keys.json'), // Read the file | |
compress: { | |
assets: { | |
options: { | |
mode: 'gzip' | |
}, | |
}, | |
files: [ | |
{expand: true, cwd: "assets/", src: ['**/*.css', '**/*.js'], dest: 'dist/assets/'}, | |
] | |
}, | |
aws_s3: { | |
options: { | |
accessKeyId: "<%= aws.AWSAccessKeyId %>", | |
secretAccessKey: "<%= aws.AWSSecretKey %>", | |
region: 'eu-west-1', | |
}, | |
production: { | |
options: { | |
bucket: 'nzk-test-bucket', | |
}, | |
files: [ | |
{expand: true, cwd: "dist/assets/", src: ['**/*.css', '**/*.js'], params: {ContentEncoding: 'gzip'}}, | |
] | |
}, | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This method doesn't set the ContentType. Here's how I did it in production.
Then running
grunt aws_s3
will copy the parent files, the static files, and overwrite the static files you specify with gzipped versions and the correct headers.