Skip to content

Instantly share code, notes, and snippets.

@lordhumunguz
Last active August 29, 2015 14:02
Show Gist options
  • Save lordhumunguz/c1bb1b505177d2f56b4f to your computer and use it in GitHub Desktop.
Save lordhumunguz/c1bb1b505177d2f56b4f to your computer and use it in GitHub Desktop.
A sample grunt file for {blog url}
module.exports = (grunt) ->
timestamp = Date.now().toString()
grunt.initConfig
env: grunt.file.readJSON '.env.json'
s3:
options:
key: '<%= env.AWS.AccessKeyId %>'
secret: '<%= env.AWS.SecretKey %>'
bucket: '<%= env.AWS.bucket %>'
access: 'public-read'
headers:
"Cache-Control": "max-age=630720000, public" # 2 years
"Expires": new Date(Date.now() + 630720000).toUTCString()
prod:
upload: [
{
src: 'dist/assets/*'
dest: timestamp + '/assets/'
}
]
redis:
options:
prefix: timestamp + ':'
currentDeployKey: timestamp
manifestKey: 'manifest_ten_deploys'
manifestSize: 10
dev:
options:
host: '<%= env.REDISTOGO.development.host %>'
port: '<%= env.REDISTOGO.development.port %>'
files: src : ["dist/index.html"]
prod:
options:
host: '<%= env.REDISTOGO.production.host %>'
port: '<%= env.REDISTOGO.production.port %>'
connectionOptions: auth_pass: '<%= env.REDISTOGO.production.password %>'
files: src : ["dist/index.html"]
hashres:
prod:
# files to be fingerprinted
src: [
'dist/assets/app.js'
'dist/assets/vendor.css'
'dist/assets/app.css'
]
# file that needs references rewritten
dest: 'dist/index.html'
cdn:
options:
cdn: "http://d27wo4aoft680v.cloudfront.net/" + timestamp
flatten: true
dist:
src: ['./dist/index.html']
shell:
options:
stdout: true
stderr: true
failOnError: true
dev: command: 'ember build --environment=development --output-path ../appb_api/public'
prod: command: 'ember build --environment=production'
grunt.loadNpmTasks('grunt-s3')
grunt.loadNpmTasks('grunt-hashres')
grunt.loadNpmTasks('grunt-redis')
grunt.loadNpmTasks('grunt-cdn')
grunt.loadNpmTasks('grunt-shell')
# Default task(s). flag can be '-prod' or '-p'
target = if grunt.option('prod') or grunt.option('p') then 'prod' else 'dev'
if target is 'prod'
grunt.registerTask 'default', [ "shell:#{target}"
'hashres'
'cdn'
's3'
"redis:#{target}" ]
else
grunt.registerTask 'default', [ "shell:#{target}" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment