-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathGruntfile.js
98 lines (96 loc) · 2.73 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
module.exports = function (grunt) {
grunt.initConfig({
htmlmin: {
options: {
collapseWhitespace: true,
preserveLineBreaks: false
},
files: {
expand: true,
cwd: '_book',
src: ['*.html', '2.9/*.html'],
dest: 'dist/'
}
},
cssmin: {
files: {
expand: true,
cwd: '_book',
src: ['gitbook/**/*.css', '2.9/gitbook/**/*.css'],
dest: 'dist/'
}
},
uglify: {
main: {
files: [{
expand: true,
cwd: '_book',
src: ['gitbook/**/*.js', '2.9/gitbook/**/*.js', '!gitbook/gitbook-plugin-anchor-navigation-ex/**/*.js', '!2.9/gitbook/gitbook-plugin-anchor-navigation-ex/**/*.js'],
dest: 'dist/'
}]
}
},
unescape: {
files: {
src: ['_book/*.html', '_book/2.9/*.html'],
dist: 'dist/'
}
},
'json-minify': {
build: {
files: 'book.json'
}
},
replace: {
html: {
src: ['_book/*.html', '_book/2.9/*.html'],
overwrite: true,
replacements: [{
form: '<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">',
to: '<link rel="apple-touch-icon-precomposed" sizes="152x152" href="https://cdn.jsdelivr.net/gh/wangding/i@master/favicon.svg">'
}, {
from: '<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">',
to: '<link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/wangding/i@master/favicon.svg">'
}]
}
},
qiniu_qupload: {
default_options: {
options: {
ak: 'QINIU_AK',
sk: 'QINIU_SK',
bucket: 'gb-selenium',
assets: [{src: '_book', prefix: ''}]
}
}
},
copy: {
html: {
files: [{
expand: true,
cwd: 'dist',
src: ['*.html', '2.9/*.html'],
dest: '_book/'
}]
},
js: {
files: [{
expand: true,
cwd: 'dist',
src: ['gitbook/**', '2.9/gitbook/**'],
dest: '_book/'
}]
}
}
});
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-unescape-html');
grunt.loadNpmTasks('grunt-json-minify');
grunt.loadNpmTasks('@wangding/grunt-qiniu-qupload');
grunt.registerTask('minify', ['unescape', 'copy:html', 'replace', 'htmlmin', 'cssmin', 'uglify', 'copy:html', 'copy:js', 'json-minify']);
grunt.registerTask('upload', ['qiniu_qupload']);
};