forked from devfreebooks/devfreebooks.github.io
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
94 lines (90 loc) · 2.54 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const harp = require('./harp.json');
module.exports = (grunt) => {
const config = {
// Clean folders =================================
clean: {
www: ['www']
},
// ENV vars ======================================
env: {
dev: {
NODE_ENV: 'development'
},
prod: {
NODE_ENV: 'production'
}
},
// Compress ======================================
compress: {
main: {
options: {
mode: 'gzip',
level: 9,
pretty: true
},
files: [
{ expand: true, flatten: true, src: ['www/assets/js/*.js'], dest: 'www/assets/js', ext: '.gz.js' },
{ expand: true, flatten: true, src: ['www/assets/css/*.css'], dest: 'www/assets/css', ext: '.gz.css' }
]
}
},
// Image Optim ===================================
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'public/assets/images',
src: ['**/*.{png,jpg,gif}'],
dest: 'public/assets/images'
}]
}
},
// Exec Feed Generator ===========================
shell: {
feed: {
command: 'mkdir -p www && node feed.js'
},
categories: {
command: 'node categories.js'
}
},
// Sitemap =======================================
sitemaps: {
default: {
options: {
baseUrl: harp.globals.root_url.production,
contentRoot: 'www/',
dest: 'www/'
},
files: [{
expand: true,
cwd: 'www/',
src: '**/*.html'
}]
}
},
// Github Pages ==================================
'gh-pages': {
options: {
base: 'www',
repo: harp.globals.github_repo,
message: `Deploying ${harp.globals.title}`,
branch: 'master'
},
src: '**/*'
}
};
grunt.initConfig(config);
grunt.loadNpmTasks('grunt-gh-pages');
grunt.loadNpmTasks('grunt-env');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-sitemaps');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-newer');
grunt.registerTask('prebuild:dev', ['clean', 'env:dev', 'shell:categories', 'newer:imagemin']);
grunt.registerTask('prebuild:prod', ['clean', 'env:prod', 'shell:categories', 'newer:imagemin']);
grunt.registerTask('build:prod', ['shell:feed', 'compress', 'sitemaps']);
grunt.registerTask('deploy:prod', ['gh-pages', 'clean']);
};