This repository has been archived by the owner on Dec 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Gruntfile.js
146 lines (139 loc) · 3.87 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
/**
* @license
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* global module */
module.exports = function(grunt) {
// Project configuration.
const COMMON_SOURCE = [
'html/**/*',
'css/**/*',
'js/server/**/*',
'js/client/**/*',
'images/**/*'
];
const BOWER_OPTIONS = {
keepExpandedHierarchy: false,
packageSpecific: {
'fancytree': {
files: [
'dist/src/jquery.fancytree.js',
'dist/src/jquery.fancytree.filter.js',
'dist/src/jquery.fancytree.table.js',
'dist/src/jquery.fancytree.ariagrid.js',
'dist/skin-win8/ui.fancytree.css',
'dist/skin-win8/*.gif',
]
},
}
};
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: [ 'build' ],
copy: {
app: {
files: [
{ src: COMMON_SOURCE, dest: 'build/app/' },
{ src: 'js/app/*.js', dest: 'build/app/' },
{ src: ['app/manifest.json'], dest: 'build/' },
]
},
extension: {
files: [
{ src: COMMON_SOURCE, dest: 'build/extension/' },
{ src: 'js/extension/*.js', dest: 'build/extension/' },
{ src: ['extension/manifest.json'], dest: 'build/' },
]
}
},
modify_json: {
options: {
fields: {
version: '<%= pkg.version %>'
},
indent: 2
},
app: {
files: {
"build/app": ['build/app/manifest.json']
}
},
extension: {
files: {
"build/extension": ['build/extension/manifest.json']
}
}
},
eslint: {
target: ['js/**/*.js']
},
compress: {
app: {
options: {
archive: 'build/package/app.zip'
},
files: [
{ src: ['./**/*'], cwd:'build/app', expand: true, dest: '' }
],
},
extension: {
options: {
archive: 'build/package/extension.zip'
},
files: [
{ src: ['./**/*'], cwd:'build/extension', expand: true, dest: '' }
],
}
},
watch: {
// TODO split into separate watch tasks for app/extension,
// but it doesn't really matter, may as well do everything on any change
all: {
files: COMMON_SOURCE.concat([
'js/app/**/*',
'app/manifest.json',
'js/extension/**/*',
'extension/manifest.json'
]),
tasks: ['app', 'extension'],
options: {
spawn: false
},
}
},
bower: {
app: {
dest: 'build/app/third_party/',
options: BOWER_OPTIONS
},
extension: {
dest: 'build/extension/third_party/',
options: BOWER_OPTIONS
}
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-bower');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-modify-json');
grunt.registerTask('app', ['copy:app', 'modify_json:app', 'bower:app']);
grunt.registerTask('extension',
['copy:extension', 'modify_json:extension', 'bower:extension']);
grunt.registerTask('package', ['compress:extension', 'compress:app']);
grunt.registerTask('default', ['eslint', 'clean', 'extension', 'app']);
};