forked from vinta/pangu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
174 lines (158 loc) · 3.98 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
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('bower.json'),
clean: {
build: [
'dist/',
'browser_extensions/chrome_dev/',
'browser_extensions/chrome_dist/'
],
finish: [
'dist/pangu.safe.js',
]
},
copy: {
build: {
files: [
{
src: 'dist/pangu.min.js',
dest: 'browser_extensions/chrome/vendors/pangu.min.js'
},
{
expand: true,
cwd: 'browser_extensions/chrome/',
src: [
'_locales/**/*',
'images/icon_*',
'js/**/*',
'pages/**/*',
'sounds/**/*',
'stylesheets/**/*.css',
'vendors/**/*',
'manifest.json'
],
dest: 'browser_extensions/chrome_dev/'
}
]
},
package: {
files: [
{
expand: true,
cwd: 'browser_extensions/chrome_dev/',
src: '**',
dest: 'browser_extensions/chrome_dist/'
},
{
src: '/Users/vinta/Dropbox/Developer/Projects/paranoid-auto-spacing/key.pem',
dest: 'browser_extensions/chrome_dist/key.pem'
}
]
}
},
karma: {
build: {
options: {
// base path, that will be used to resolve files and exclude
basePath: '',
// start these browsers
browsers: [
'PhantomJS'
],
// list of files / patterns to load in the browser
files: [
'dist/*.js',
'tests/lib/jquery/jquery-1.10.2.min.js',
'tests/lib/jasmine-jquery/jasmine-jquery.js',
'tests/spec/**/*.js',
{
pattern: 'tests/fixtures/**/*.html',
included: false,
served: true
}
],
// list of files to exclude
exclude: [],
// frameworks to use
frameworks: [
'jasmine'
],
// preprocessors allow you to do some work with your files before they get served to the browser.
preprocessors: {
'**/*.html': []
},
// test results reporter to use, possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: [
'progress'
],
// continuous Integration mode, if true, it capture browsers, run tests and exit
singleRun: true
}
}
},
// remove console.log()
strip: {
build: {
src: 'src/pangu.js',
dest: 'dist/pangu.safe.js'
},
package: {
src: 'browser_extensions/chrome_dist/js/*.js',
options: {
inline: true
}
}
},
uglify: {
options: {
banner: grunt.file.read('src/banner.js')
},
build: {
src: 'dist/pangu.safe.js',
dest: 'dist/pangu.min.js'
}
},
watch: {
build: {
files: [
'src/**/*',
'browser_extensions/chrome/**/*',
'!browser_extensions/chrome/vendors/pangu.min.js'
],
tasks: [
'build'
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks('grunt-strip');
grunt.registerTask('build', [
'clean:build',
'strip:build',
'uglify',
'copy:build',
'clean:finish'
]);
grunt.registerTask('test', [
'karma'
]);
// 準備打包到 Chrome Web Store
// browser_extensions/chrome_dev/ 是開發用的
// browser_extensions/chrome_dist/ 是打包用的
grunt.registerTask('package', [
'build',
'copy:package',
'strip:package'
]);
grunt.registerTask('default', [
'build',
'test',
'package'
]);
};