forked from tusharmath/Super-Cache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
118 lines (100 loc) · 2.55 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
var _options = {
packageFile: './bin/app.zip',
applicationPath: './bin/mt-downloader.app/Contents/Resources'
};
var _config = {
zip: {
createPackage: {
cwd: 'bin/src/',
src: ['./bin/src/manifest.json',
'./bin/src/background/bg.min.js',
'./bin/src/snapshots/*',
'./bin/src/popup/index.html',
'./bin/src/popup/site.min.js',
'./bin/src/popup/site.css'],
dest: _options.packageFile
}
},
release: {
options: {
npm: false
}
},
uglify: {
dist: {
files: {
'./bin/src/background/bg.min.js': [
"src/background/UtilKeys.js",
"src/background/HostsDb.js",
"src/background/headersManipulator.js",
"src/background/SuperCacheLiveTabs.js",
"src/background/ApplicationIcon.js",
"src/background/MainBackground.js"],
'./bin/src/popup/site.min.js': ['src/popup/*.js']
}
}
},
manifest_merge: {
foo: {
pkg: './',
src: './src',
dest: './bin/src'
}
},
"string-replace": {
index: {
files: {
"./bin/": "./src/popup/index.html"
},
options: {
replacements: [{
pattern: /site\.js/g,
replacement: "site.min.js"
}]
}
}
},
copy: {
css_main: {
files: [{
expand: true,
src: ['./src/popup/*.css'],
dest: './bin/src/popup/',
flatten: true
}]
},
images: {
files: [{
expand: true,
src: ['./src/snapshots/*'],
dest: './bin'
}]
}
}
};
module.exports = function(grunt) {
grunt.file.delete('./bin');
grunt.initConfig(_config);
_config.pkg = grunt.file.readJSON('package.json');
grunt.loadNpmTasks('grunt-zip');
grunt.loadNpmTasks('grunt-release');
grunt.loadNpmTasks('grunt-contrib-copy');
//grunt.loadNpmTasks('grunt-contrib-watch');
//grunt.loadNpmTasks('grunt-contrib-nodeunit');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-string-replace');
grunt.registerMultiTask('manifest_merge', 'Log stuff.', function() {
var pkg = this.data.pkg + '/package.json';
var src = this.data.src + '/manifest.json';
var dest = this.data.dest + '/manifest.json';
var pkgContent = grunt.file.readJSON(pkg);
var srcContent = grunt.file.readJSON(src);
srcContent.name = pkgContent.name;
srcContent.version = pkgContent.version;
srcContent.description = pkgContent.description;
srcContent.background.scripts = ['background/bg.min.js'];
grunt.file.write(dest, JSON.stringify(srcContent));
});
grunt.registerTask('pack', ['uglify', 'manifest_merge', 'string-replace', 'copy', 'zip']);
grunt.registerTask('pack-release', ['uglify', 'manifest_merge', 'string-replace', 'copy', 'zip', 'release']);
};