#create package.json { "name": "my-project-name", "version": "0.1.0", "devDependencies": { "grunt": "~0.4.2", "grunt-contrib-jshint": "~0.6.3", "grunt-contrib-nodeunit": "~0.2.0", "grunt-contrib-uglify": "~0.2.2", "grunt-aws-s3": "~0.8.0" } } #Grunt file ###Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
aws: grunt.file.readJSON('aws.json'),
aws_s3: {
options: {
accessKeyId: '<%= aws.key %>', // Use the variables
secretAccessKey: '<%= aws.secret %>', // You can also use env variables
region: 'us-east-1', //can be found from url when u click on your bucket
uploadConcurrency: 10, // 10 simultaneous uploads
downloadConcurrency: 5 // 5 simultaneous downloads
},
staging: {
options: {
bucket: '<%= aws.bucket %>',
differential: true // Only uploads the files that have changed, //needs dest
},
files: [
/* {dest: 'app/', differential:false,'action': 'delete'},*/
{'action': 'upload', expand: true, cwd: './../dist/', src: ['**'], dest: 'app/', stream: true, differential: true} //I need to upoad
//{'action': 'upload', expand: true, cwd: './../dist/', src: ['**'], stream: true, differential: false} To force upload
]
},
}
});
grunt.loadNpmTasks('grunt-aws-s3');
};
aws.json refers to a simple json file in the same directory
npm install
grunt aws_s3
#Sample Output
Uploading to https://s3.amazonaws.com/bucket-name/
.......................
#References