Created
March 22, 2016 16:02
-
-
Save NSBum/72b6627e44565fb0712d to your computer and use it in GitHub Desktop.
updated grunt file for my blog
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
module.exports = function(grunt) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
aws: grunt.file.readJSON('grunt-aws.json'), | |
shell: { | |
clean: { | |
command: 'hexo clean' | |
}, | |
generate: { | |
command: 'hexo generate' | |
}, | |
server: { | |
command: 'hexo server' | |
}, | |
fixImageCacheHeaders: { | |
options: { | |
stdout: true, | |
execOptions: { | |
cwd: '.' | |
} | |
}, | |
command: 'python fixCacheHeaders.py' | |
} | |
}, | |
robotstxt: { | |
dev: { | |
dest: 'public/', | |
policy: [{ | |
ua: '*', | |
disallow: '/' | |
}, { | |
sitemap: ['http://localhost:4000/sitemap.xml'] | |
}, { | |
host: 'localhost:4000' | |
}] | |
}, | |
staging: { | |
dest: 'public/', | |
policy: [{ | |
ua: '*', | |
disallow: '/' | |
}, { | |
sitemap: ['http://localhost:4000/sitemap.xml'] | |
}, { | |
host: 'localhost:4000' | |
}] | |
}, | |
production: { | |
dest: 'public/', | |
policy: [{ | |
ua: '*', | |
allow: '/' | |
}, { | |
sitemap: ['http://ojisanseiuchi.com/sitemap.xml'] | |
}, { | |
host: 'ojisanseiuchi.com' | |
}] | |
} | |
}, | |
sitemap: { | |
dev: { | |
siteRoot: 'public/', | |
homepage: 'http://localhost:4000' | |
}, | |
staging: { | |
siteRoot: 'public/', | |
homepage: 'http://staging.ojisanseiuchi.com' | |
}, | |
production: { | |
siteRoot: 'public/', | |
homepage: 'http://ojisanseiuchi.com' | |
} | |
}, | |
s3: { | |
options: { | |
accessKeyId: '<%= aws.accessIdProduction %>', | |
secretAccessKey: '<%= aws.accessKeyProduction %>', | |
bucket: '<%= aws.bucketProduction %>', | |
access: 'public-read', | |
headers: { | |
// Two Year cache policy (1000 * 60 * 60 * 24 * 730) | |
"Cache-Control": "max-age=630720000, public", | |
"Expires": new Date(Date.now() + 63072000000).toUTCString() | |
} | |
}, | |
public: { | |
cwd: "public/", | |
src: "**" | |
} | |
}, | |
}); | |
//Load NPM tasks | |
grunt.loadNpmTasks('grunt-shell'); | |
grunt.loadNpmTasks('grunt-robots-txt') | |
grunt.loadNpmTasks('grunt-sitemap'); | |
grunt.loadNpmTasks('grunt-aws'); | |
//Grunt tasks | |
grunt.registerTask('default', ['shell:clean', 'shell:generate', 'sitemap:dev', 'robotstxt:dev', 'shell:server']); | |
//grunt.registerTask('staging', ['shell:clean','shell:generate','sitemap:staging', 'robotstxt:staging', 's3:staging']); | |
grunt.registerTask('deploy', ['shell:clean', 'shell:generate', 'sitemap:production', 'robotstxt:production', 's3']); | |
grunt.registerTask('logpre', function() { | |
grunt.log.writeln('*** Fix metadata ***'); | |
}); | |
grunt.registerTask('logpost', function() { | |
grunt.log.writeln('*** Fixed metadata ***'); | |
}) | |
grunt.registerTask('deployf', function() { | |
grunt.task.run(['shell:clean', 'shell:generate', 'sitemap:production', 'robotstxt:production', 's3']); | |
grunt.task.run('logpre'); | |
grunt.task.run('shell:fixImageCacheHeaders'); | |
grunt.task.run('logpost'); | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment