-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
210 lines (205 loc) · 9.13 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
module.exports = function (grunt) {
// prod will get published.
var ENV = (grunt.option('prod') && 'prod') || 'dev';
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
// define the files to lint
files: ['Gruntfile.js', 'src/**/*(!*.generated).js', 'test/**/*.js'],
// configure JSHint (documented at http://www.jshint.com/docs/)
options: {
// more options here if you want to override JSHint defaults
globals: {
jQuery: true
}
}
},
concat: {
options: {
// define a string to put between each file in the concatenated output
separator: ';'
},
dist: {
// the files to concatenate
src: ['src/**/panel/js/**/*.js'],
// the location of the resulting JS file
dest: 'dist/panel/panel.js'
},
ngDependencyGraph: {
src: [
'vendor/ng-dependency-graph/scripts/**/*.js',
'!**/*.spec.js'
],
dest: 'lib/ng-dependency-graph/ng-dependency-graph.js'
}
},
uglify: {
options: {
// the banner is inserted at the top of the output
banner: '/*! <%= pkg.name%> v<%= pkg.version %> | <%= grunt.template.today("dd-mm-yyyy") %> | <%= pkg.homepage%> */\n'
},
dist: {
files: {
'dist/panel/panel.min.js': ['<%= concat.dist.dest %>'],
'dist/background/background.min.js': ['src/background/background.js'],
'dist/content-script/content-script.min.js': ['src/content-script/content-script.js'],
'dist/message.min.js': ['src/message.js']
}
},
inject: {
files: {
'src/content-script/inject/angularinspector.min.js': ['src/content-script/inject/angularinspector.js']
}
},
'uglify-inspector': {
options: {
preserveComments: false,
mangle: false,
compress: false,
beatify: true
},
files: {
'src/content-script/inject/angularinspector.min.js': ['src/content-script/inject/angularinspector.js']
}
}
},
copy: {
src: {
files: [
// src files
// copy all minified in dist to src and rename to .js
{expand: true, cwd: 'dist/', src: '**/*.min.js', dest: 'zip/src/', ext: '.js'},
{expand: true, cwd: 'src/panel/css/', src: '*.css', dest: 'zip/src/panel/'},
{src: ['src/panel/partials/*.html'], dest: 'zip/'},
{src: 'src/devtools/*', dest: 'zip/'},
{src: 'src/content-script/inject/angularinspector.min.js', dest: 'zip/'},
{expand: true, cwd: 'src/popup', src: ['**/*.js', '*.html', '*.css'], dest: 'zip/src/popup'}
]
},
'lib-angular-mock': {
options: {
process: function (content) {
return content.replace('(function(window, angular) {', 'window.injectMock=(function(window, angular) {')
.replace('})(window, window.angular);', '});');
}
},
src: 'node_modules/angular-mocks/angular-mocks.js',
dest: 'lib/angular-mocks.js'
},
// compile and generate lib folder
ngDependencyGraph: {
files: [
{
expand: true,
cwd: 'vendor/ng-dependency-graph/',
src: ['**/*.html', '**/*.css'],
dest: 'lib/ng-dependency-graph/'
}]
},
lib: {
files: [
// angular
{src: 'node_modules/angular/angular.min.js', dest: 'lib/angular.min.js'},
{src: 'node_modules/angular-animate/angular-animate.min.js', dest: 'lib/angular-animate.min.js'},
// jquery
{src: 'node_modules/jquery/dist/jquery.min.js', dest: 'lib/jquery.min.js'},
// admin-lte, bootstrap and font-awesome
{
expand: true,
cwd: 'node_modules/admin-lte/',
flatten: true,
src: ['bootstrap/js/bootstrap.min.js', 'dist/js/app.min.js'],
dest: 'lib/admin-lte/js/'
},
{
expand: true,
flatten: true,
src: ['node_modules/font-awesome/css/font-awesome.min.css', 'node_modules/admin-lte/bootstrap/css/bootstrap.min.css', 'node_modules/admin-lte/dist/css/AdminLTE.min.css', 'node_modules/admin-lte/dist/css/skins/skin-blue.min.css'],
dest: 'lib/admin-lte/css/'
},
{
src: 'node_modules/admin-lte/bootstrap/fonts/glyphicons-halflings-regular.ttf',
dest: 'lib/admin-lte/fonts/glyphicons-halflings-regular.ttf'
},
{
src: 'node_modules/admin-lte/bootstrap/fonts/glyphicons-halflings-regular.woff',
dest: 'lib/admin-lte/fonts/glyphicons-halflings-regular.woff'
},
{
src: 'node_modules/admin-lte/bootstrap/fonts/glyphicons-halflings-regular.woff2',
dest: 'lib/admin-lte/fonts/glyphicons-halflings-regular.woff2'
},
{
src: 'node_modules/font-awesome/fonts/fontawesome-webfont.woff2',
dest: 'lib/admin-lte/fonts/fontawesome-webfont.woff2'
},
// react
{src: 'node_modules/react/dist/react.min.js', dest: 'lib/react.min.js'},
{src: 'node_modules/react-dom/dist/react-dom.min.js', dest: 'lib/react-dom.min.js'},
// other vendor files
{expand: true, cwd: 'vendor/', src: ['**','!**/ng-dependency-graph/**'], dest: 'lib/'}
]
}
},
compress: {
main: {
options: {
'archive': function () {
var manifest = grunt.file.readJSON('manifest.json'),
pkg = grunt.config('pkg');
if (manifest.version !== pkg.version) {
throw new Error('version must be same for both package.json and manifest.json.\n package.json = "' + pkg.version + '"\nmanifest.json = "' + manifest.version + '"');
}
return 'zip/birbaljs-extension-v' + pkg.version + '.zip';
}
},
files: [
{expand: true, cwd: 'zip/', src: ['**/*'], dest: '/'},
{src: ['lib/**', 'img/*', 'manifest.json', 'LICENSE', 'README.md'], dest: '/'}
]
}
},
template: {
index: {
options: {
data: function () {
return {env: ENV};
}
},
files: {
'src/panel/partials/index.html': ['src/panel/partials/index.html.template']
}
}
},
clean: {
compress: ['zip/**'],
'build-local': ['dist/**', 'lib/**', 'src/panel/partials/index.html', 'src/**/*.min.js', 'src/**/*.generated.js'],
popup: ['src/popup/*.generated.js'],
inject: ['src/content-script/inject/*.min.js'],
dist: ['dist/**']
},
connect: {
example: {
options: {
port: 8080,
keepalive: true,
open: 'http://localhost:8080/example/exampleApp.html'
}
}
}
});
// time for each task
require('time-grunt')(grunt);
require('jit-grunt')(grunt);
// Default task(s).
grunt.registerTask('default', ['jshint']);
// generate injector script
grunt.registerTask('build-inject', ['clean:inject', 'uglify:inject']);
// copy ng-dependency-graph files to lib
grunt.registerTask('build-ng-dependency-graph', ['concat:ngDependencyGraph', 'copy:ngDependencyGraph']);
// creating zip file for distribution
grunt.registerTask('build-extension', ['jshint', 'template', 'concat', 'uglify', 'copy', 'compress']);
// for development
grunt.registerTask('build', ['jshint', 'build-inject', 'build-ng-dependency-graph', 'copy:lib', 'copy:lib-angular-mock', 'template']);
};