forked from rhiokim/haroopad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
231 lines (212 loc) · 8.64 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
module.exports = function(grunt) {
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-shell');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
vendors: 'src/js/vendors',
clean: {
build: [ 'build/*' ],
release: [ 'build/haroopad.app' ]
},
cssmin: {
compress: {
options: {
keepSpecialComments: 0
},
files: {
"build/haroopad/css/codemirror.min.css": [
'<%= vendors %>/CodeMirror/lib/codemirror.css',
'<%= vendors %>/CodeMirror/theme/ambiance.css',
'<%= vendors %>/CodeMirror/theme/blackboard.css',
'<%= vendors %>/CodeMirror/theme/cobalt.css',
'<%= vendors %>/CodeMirror/theme/elegant.css',
'<%= vendors %>/CodeMirror/theme/erlang-dark.css',
'<%= vendors %>/CodeMirror/theme/lesser-dark.css',
'<%= vendors %>/CodeMirror/theme/monokai.css',
'<%= vendors %>/CodeMirror/theme/neat.css',
'<%= vendors %>/CodeMirror/theme/night.css',
'<%= vendors %>/CodeMirror/theme/rubyblue.css',
'<%= vendors %>/CodeMirror/theme/solarized.css',
'<%= vendors %>/CodeMirror/theme/twilight.css',
'<%= vendors %>/CodeMirror/theme/vibrant-ink.css',
'<%= vendors %>/CodeMirror/theme/xq-dark.css'
],
"build/haroopad/css/haroopad.min.css": [
'src/css/bootstrap.css',
'src/css/todc-bootstrap.css',
'src/css/bootstrapSwitch.css',
'src/css/select2.css',
'src/css/font-awesome.min.css',
'src/css/bootstrap-modal.css',
'src/css/app.css',
],
"build/haroopad/css/viewer.min.css": [
'src/css/viewer.css'
]
}
}
},
concat: {
dist: {
files: {
'build/haroopad.js': [
'<%= vendors %>/underscore.js',
'<%= vendors %>/marked.js',
'<%= vendors %>/highlight.pack.js',
'src/js/app/before.bin.js',
'<%= vendors %>/jquery-1.9.1.js',
'<%= vendors %>/backbone.js',
'<%= vendors %>/bootstrap.min.js',
'<%= vendors %>/bootstrapSwitch.js',
'<%= vendors %>/bootstrap-modalmanager.js',
'<%= vendors %>/bootstrap-modal.js',
'<%= vendors %>/select2.js',
'<%= vendors %>/js-url.js',
'src/js/app/after.bin.js'
],
'build/vendors.js': [
'<%= vendors %>/require.js'
],
'build/codemirror.js': [
'<%= vendors %>/CodeMirror/lib/codemirror.js',
'<%= vendors %>/CodeMirror/addon/edit/continuelist.js',
'<%= vendors %>/CodeMirror/addon/edit/closebrackets.js',
'<%= vendors %>/CodeMirror/addon/mode/overlay.js',
'<%= vendors %>/CodeMirror/mode/xml/xml.js',
'<%= vendors %>/CodeMirror/mode/gfm/gfm.js',
'<%= vendors %>/CodeMirror/mode/htmlmixed/htmlmixed.js',
'<%= vendors %>/CodeMirror/mode/markdown/markdown.js',
'<%= vendors %>/CodeMirror/keymap/vim.js'
]
}
}
},
uglify: {
pad: {
options: {
// mangle: true,
// compress: true
},
files: {
'build/haroopad.bin.js': [
'build/haroopad.js'
],
'build/haroopad/js/vendors.min.js': [
'build/vendors.js'
],
'build/haroopad/js/codemirror.min.js': [
'build/codemirror.js'
]
}
},
viewer: {
options: {},
files: {
'build/haroopad/js/viewer.min.js': [
'<%= vendors %>/jquery-1.9.1.min.js',
'<%= vendors %>/js-url.js',
'src/js/viewer/main.js',
]
}
}
},
copy: {
main: {
files: [
{ expand: true, cwd: 'src/font/', src: [ '**' ], dest: 'build/haroopad/font/' },
{ expand: true, cwd: 'src/img/', src: [ '**' ], dest: 'build/haroopad/img/' },
{ expand: true, cwd: 'src/css/code/', src: [ '**' ], dest: 'build/haroopad/css/code/' },
{ expand: true, cwd: 'src/css/markdown/build/', src: [ '**' ], dest: 'build/haroopad/css/markdown/' },
{ src: 'src/pad.bin.html', dest: 'build/haroopad/pad.html' },
{ src: 'src/viewer.bin.html', dest: 'build/haroopad/viewer.html' },
{ src: 'src/package.bin.json', dest: 'build/haroopad/package.json' },
{ src: 'src/logo.png', dest: 'build/haroopad/logo.png' },
{ src: 'src/css/keys.css', dest: 'build/haroopad/css/keys.css' },
{ src: 'src/css/select2.png', dest: 'build/haroopad/css/select2.png' }
]
},
debug: {
files: [
{ expand: true, cwd: 'src/font/', src: [ '**' ], dest: 'build/haroopad.app/Contents/Resources/app.nw/font/' },
{ expand: true, cwd: 'src/img/', src: [ '**' ], dest: 'build/haroopad.app/Contents/Resources/app.nw/img/' },
{ expand: true, flatten: true, src: [ 'src/css/*' ], dest: 'build/haroopad.app/Contents/Resources/app.nw/css/', filter:'isFile' },
{ expand: true, cwd: 'src/js/', src: [ '**' ], dest: 'build/haroopad.app/Contents/Resources/app.nw/js/' },
{ expand: true, cwd: 'src/tpl/', src: [ '**' ], dest: 'build/haroopad.app/Contents/Resources/app.nw/tpl/' },
{ expand: true, cwd: 'src/css/code/', src: [ '**' ], dest: 'build/haroopad.app/Contents/Resources/app.nw/css/code/' },
{ expand: true, cwd: 'src/css/viewer/', src: [ '**' ], dest: 'build/haroopad.app/Contents/Resources/app.nw/css/viewer/' },
{ expand: true, cwd: 'src/css/markdown/build/', src: [ '**' ], dest: 'build/haroopad.app/Contents/Resources/app.nw/css/markdown/' },
{ src: 'src/pad.html', dest: 'build/haroopad.app/Contents/Resources/app.nw/pad.html' },
{ src: 'src/viewer.html', dest: 'build/haroopad.app/Contents/Resources/app.nw/viewer.html' },
{ src: 'src/package.json', dest: 'build/haroopad.app/Contents/Resources/app.nw/package.json' },
{ src: 'src/css/keys.css', dest: 'build/haroopad.app/Contents/Resources/app.nw/css/keys.css' },
{ src: 'src/css/select2.png', dest: 'build/haroopad.app/Contents/Resources/app.nw/css/select2.png' },
{ src: 'lib/haroopad.icns', dest: 'build/haroopad.app/Contents/Resources/nw.icns' },
{ src: 'src/logo.png', dest: 'build/haroopad.app/Contents/Resources/app.nw/logo.png' },
{ src: 'About.md', dest: 'build/haroopad.app/Contents/Resources/app.nw/About.md' }
]
},
build: {
files: [
{ expand: true, cwd: 'build/haroopad/', src: [ '**' ], dest: 'build/haroopad.app/Contents/Resources/app.nw/' }
]
}
},
shell: {
cpLib: {
command: 'cp -R lib/nw.app build/haroopad.app'
},
cpZipSrc: {
command: 'cp -R ./build/haroopad ./build/haroopad.app/Contents/Resources/app.nw'
},
exec: {
command: 'open ./build/haroopad.app'
},
/* v8 heap snapshot for protect source */
ss_darwin: {
command: 'nwsnapshot --extra_code ./build/haroopad.bin.js ./build/haroopad/js/haroopad.bin'
},
deploy: {
command: 'cp -R ./build/haroopad.app /Applications'
}
},
replace: {
info: {
options: {
variables: {
version: '<%= pkg.version %>',
title: '<%= pkg.name %>'
},
prefix: '@@'
},
files: {
'./build/haroopad.app/Contents/Info.plist': [
'Info.plist'
]
}
}
},
requirejs: {
compile: {
options: {
name: 'haroopad',
baseUrl: "src/js/app",
mainConfigFile: "src/js/app/haroopad.js",
out: "build/haroopad/js/modules.js",
preserveLicenseComments: false
}
}
}
});
grunt.registerTask('default', [ 'clean', 'concat', 'uglify:pad', 'uglify:viewer', 'cssmin', 'copy:main', 'requirejs' ]);
grunt.registerTask('deploy', [ 'shell:deploy']);
grunt.registerTask('debug', [ 'clean:release', 'shell:cpLib', 'copy:debug', 'replace:info', 'shell:exec' ]);
grunt.registerTask('build', [ 'clean:release', 'shell:cpLib', 'copy:build', 'replace:info', 'shell:ss_darwin', 'shell:exec' ]);
};