Answer the question
In order to leave comments, you need to log in
How to properly use the NPM package grunt-aws?
You need to set up uploading the code to a remote server that is running on Amazon.
What I did:
1) Added the package to package.json
2) Installed the package using the npm install command
3) Configured the Grunt config
4) Launched Grunt
Configured it like this:
aws: grunt.file.readJSON("aws-credentials.json"),
s3: {
options: {
accessKeyId: "<%= aws.accessKeyId %>",
secretAccessKey: "<%= aws.secretAccessKey %>",
bucket: "my-awesome-bucket"
},
build: {
cwd: "public/",
src: "**"
}
}
grunt.loadNpmTasks('grunt-aws');
grunt.registerTask('default', ['aws']);
Warning: Task "aws" not found. Use --force to continue.
Answer the question
In order to leave comments, you need to log in
Short description.
From Amazon, you get accessKeyId and secretAccessKey, which you write to a separate file. Next, add the name and version of the package to package.json, then add the necessary descriptions and calls to gruntfile.js , install the package, run Grunt.
1) Add to package.json
2) Create credentials.json file next to package.json and gruntfile.js
{
"accessKeyId": "Здесь ID",
"secretAccessKey": "Здесь ключ"
}
// package.json
pkg: grunt.file.readJSON('package.json'),
// Переменные каталогов проекта
project: {
app: ['public'],
assets: ['<%= project.app %>/assets'],
},
// Проталкивание файлов на S3
aws: grunt.file.readJSON("credentials.json"),
s3: {
options: {
accessKeyId: "<%= aws.accessKeyId %>",
secretAccessKey: "<%= aws.secretAccessKey %>",
bucket: "имя-каталога-куда-лить"
},
upload: {
headers: {
CacheControl: 604800
// Expires: new Date(Date.now() + 604800000).toUTCString()
},
cwd: ".",
src: [
"<%= project.app %>/*.html",
"<%= project.app %>/dist/**",
"<%= project.assets %>/fonts/**",
"<%= project.assets %>/img/*"
]
}
},
// Загрузка предварительно установленного модуля
grunt.loadNpmTasks('grunt-aws');
// Задания будут выполнятся сразу после команды grunt
grunt.registerTask('default', [ 's3']);
npm install
grunt
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question