-
Notifications
You must be signed in to change notification settings - Fork 31
/
Gruntfile.js
139 lines (130 loc) · 4.02 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
includes: {
src: '_includes/head.raw.html',
dest: '_includes/head.html'
}
},
less: {
options: {
paths: ['<%= pkg.srcRoot %>/css']
},
"<%= pkg.srcRoot %>/css/main.css": "<%= pkg.srcRoot %>/css/main.less",
"<%= pkg.srcRoot %>/css/posts.css": "<%= pkg.srcRoot %>/css/posts.less",
"<%= pkg.srcRoot %>/css/pages.css": "<%= pkg.srcRoot %>/css/pages.less",
},
useminPrepare: {
html: '_includes/head.html',
options: {
root: '.',
dest: '.tmp'
}
},
filerev: {
files: {
src: ['<%= pkg.srcRoot %>/js/**/*.js', '.tmp/<%= pkg.dstRoot %>/style.css'],
dest: '<%= pkg.dstRoot %>'
}
},
usemin: {
html: '_includes/head.html',
options: {
assetsDirs: ['.tmp']
}
},
concat: {
react_debug: {
src: ['articles.raw/articles.md', 'articles.raw/debug.html'],
dest: 'pages/1_articles.md'
},
react_release: {
src: ['articles.raw/articles.md', 'articles.raw/release.html'],
dest: 'pages/1_articles.md'
}
},
shell: {
jekyll_build: {
command: 'bundle exec jekyll build'
},
jekyll_serve: {
command: 'bundle exec jekyll serve --incremental'
},
clean_tmp: {
command: 'rm -r .tmp'
},
react_parse: {
command: './node_modules/react-tools/bin/jsx pages/ build/'
},
deploy: {
command: [
'git checkout gh-pages',
'cd _site',
'cp -r * ..',
'cd ..',
'git add .',
'git commit -m "rebuild"',
'git push origin gh-pages',
'git checkout master'
].join('&&')
}
}
});
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-usemin');
grunt.loadNpmTasks('grunt-filerev');
grunt.task.registerTask('debug_test', 'A sample task that logs stuff.', function(arg1, arg2) {
//console.log(grunt.config('cssmin.generated'));
console.log(grunt.filerev.summary);
});
grunt.registerTask('build', [
'less',
'copy:includes',
'concat:react_debug',
'shell:jekyll_build'
]);
grunt.registerTask('debug', [
'less',
'copy:includes',
'concat:react_debug',
'shell:jekyll_serve'
]);
grunt.registerTask('release', [
'less',
'copy:includes',
'concat:react_release',
'useminPrepare',
'concat:generated',
'cssmin:generated',
'filerev',
'usemin',
'shell:clean_tmp',
'shell:react_parse',
'shell:jekyll_build'
]);
grunt.registerTask('serve', [
'less',
'copy:includes',
'concat:react_release',
'useminPrepare',
'concat:generated',
'cssmin:generated',
'filerev',
'usemin',
'shell:clean_tmp',
'shell:react_parse',
'shell:jekyll_serve'
]);
grunt.registerTask('_deploy', ['shell:deploy']);
grunt.task.registerTask('deploy', 'Deploy to gh-pages', function() {
grunt.task.run(['release', '_deploy']);
})
};