Skip to content

Instantly share code, notes, and snippets.

@NSBum
Created February 26, 2016 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NSBum/5dd35074d17d93f0cf76 to your computer and use it in GitHub Desktop.
Save NSBum/5dd35074d17d93f0cf76 to your computer and use it in GitHub Desktop.
Gruntfile for my blog
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'
}
},
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']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment