-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
210 lines (203 loc) · 8.85 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
var config = require('./config.js');
var fs = require('fs');
module.exports = function(grunt) {
// generate random srting
var v = Math.random().toString(36).slice(2);
// read custom html content
var custom_content = fs.readFileSync('./public/html/custom_content.html', 'utf8');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: '\n'
},
dep: {
src: [
"public/bower_components/angular/angular.min.js",
"public/bower_components/angular-aria/angular-aria.js",
"public/bower_components/hammerjs/hammer.js",
"public/bower_components/ngprogress/build/ngProgress.min.js",
"public/bower_components/angular-ui-router/release/angular-ui-router.min.js",
"public/bower_components/angular-material/angular-material.min.js",
"public/bower_components/angular-cookie/angular-cookie.min.js",
"public/bower_components/angular-translate/angular-translate.min.js",
"public/bower_components/angular-translate-storage-cookie/angular-translate-storage-cookie.min.js",
"public/bower_components/angular-translate-loader-static-files/angular-translate-loader-static-files.min.js",
"public/bower_components/angular-animate/angular-animate.min.js",
"public/bower_components/angular-md5/angular-md5.min.js",
"public/bower_components/moment/min/moment-with-locales.min.js",
"public/bower_components/angular-moment/angular-moment.min.js",
"public/bower_components/angular-redactor/angular-redactor.js",
"public/bower_components/jquery/dist/jquery.min.js",
"public/bower_components/redactor/redactor.js",
"public/bower_components/redactor/plugins/fontsize.js",
"public/bower_components/redactor/plugins/fontcolor.js",
"public/bower_components/redactor/plugins/imagemanager.js",
"public/bower_components/redactor/plugins/fullscreen.js",
"public/bower_components/redactor/langs/zh_tw.js",
"public/bower_components/redactor/langs/zh_cn.js",
"public/bower_components/angular-disqus/angular-disqus.js",
"public/bower_components/timelinejs/build/js/storyjs-embed.js",
"public/bower_components/angular-bootstrap-datetimepicker/src/js/datetimepicker.js",
"public/bower_components/dhtmlxtree/codebase/dhtmlxtree.js",
"public/bower_components/intro.js/intro.js",
"public/bower_components/angular-intro.js/src/angular-intro.js",
"public/bower_components/ng-file-upload/dist/ng-file-upload-shim.js",
"public/bower_components/ng-file-upload/dist/ng-file-upload.js",
"public/scripts/jobactions.js",
"public/scripts/objectcache.js"
],
dest: 'public/scripts/rin.dep.js'
},
rin: {
src: [
"public/scripts/rin/build/main.build.js",
"public/scripts/rin/filter.js",
"public/scripts/rin/build/directive.build.js",
"public/scripts/rin/controller/*.js",
"public/scripts/rin/jq.js"
],
dest: 'public/scripts/rin.pr.js'
}
},
concat_css: {
options: {
},
all: {
src: [
"public/bower_components/ngprogress/ngProgress.css",
"public/bower_components/angular-material/angular-material.min.css",
"public/bower_components/angular-material/themes/red-theme.css",
"public/bower_components/angular-material/themes/pink-theme.css",
"public/bower_components/angular-material/themes/deep-orange-theme.css",
"public/bower_components/angular-material/themes/purple-theme.css",
"public/bower_components/angular-material/themes/blue-theme.css",
"public/bower_components/angular-material/themes/cyan-theme.css",
"public/bower_components/angular-material/themes/green-theme.css",
"public/bower_components/fontawesome/css/font-awesome.min.css",
"public/bower_components/redactor/redactor.css",
"public/bower_components/angular-bootstrap-datetimepicker/src/css/datetimepicker.css",
"public/bower_components/dhtmlxtree/codebase/dhtmlxtree.css",
"public/bower_components/intro.js/introjs.css",
"public/styles/style.css"
],
dest: "public/styles/app.css"
}
},
cssmin: {
options: {
keepSpecialComments: 0,
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
compress: {
files: {
'public/styles/app.min.css': [
"public/styles/app.css"
]
}
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
rin: {
options: {
mangle: true,
report: 'min',
},
files: {
'public/scripts/rin.pr.min.js': [
"public/scripts/rin.pr.js"
]
}
},
release: {
options: {
mangle: true,
report: 'min',
},
files: {
'public/scripts/rin.dep.min.js': [
"public/scripts/rin.dep.js"
],
'public/scripts/rin.pr.min.js': [
"public/scripts/rin.pr.js"
]
}
}
},
replace: {
rin_main: {
src: "public/scripts/rin/main.js",
dest: "public/scripts/rin/build/main.build.js",
replacements: [
{
from: "__VERSION__",
to: v
},
{
from: "__SHORTNAME__",
to: config.sso.shortname
},
{
from: "__CDN__",
to: config.cdn.domain_url
}
]
},
rin_directive: {
src: "public/scripts/rin/directive.js",
dest: "public/scripts/rin/build/directive.build.js",
replacements: [
{
from: "__CDN__",
to: config.cdn.domain_url
}
]
},
index: {
src: "public/html/index.html",
dest: "public/",
replacements: [
{
from: "<__CDN__>",
to: config.cdn.domain_url
},
{
from: "<__VERSION__>",
to: v
},
{
from: "<__CUSTOM_CONTENT__>",
to: custom_content
}
]
},
templates: {
src: "public/html/templates/*",
dest: "public/templates/",
replacements: [
{
from: "<__CDN__>",
to: config.cdn.domain_url
},
{
from: "<__ACGDB-PATH__>",
to: config.acgdb.pathname
}
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-concat-css');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-text-replace');
grunt.registerTask('default', ['replace', 'concat', 'uglify', 'concat_css', 'cssmin']);
grunt.registerTask('js-rin', ['replace:rin_main', 'replace:rin_directive', 'concat:rin', 'uglify:rin']);
grunt.registerTask('js', ['concat', 'uglify']);
grunt.registerTask('css', ['concat_css', 'cssmin']);
grunt.registerTask('replace_variables', ['replace', 'js-rin']);
};