-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathGruntfile.js
136 lines (130 loc) · 5.39 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
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
main: {
files: [
{expand: true, cwd: '<%= pkg.sourcePath %>/', src: ['**'], dest: '<%= pkg.buildPath %>/'}
]
},
bower: {
files: [
{src: '<%= pkg.libPath %>/jquery/dist/jquery.min.js', dest: '<%= pkg.buildPath %>/scripts/jquery.min.js'},
{src: '<%= pkg.libPath %>/webextension-polyfill/dist/browser-polyfill.min.js', dest: '<%= pkg.buildPath %>/scripts/browser-polyfill.min.js'},
{src: '<%= pkg.libPath %>/mustache/mustache.min.js', dest: '<%= pkg.buildPath %>/scripts/mustache.min.js'},
{src: '<%= pkg.libPath %>/dompurify/dist/purify.min.js', dest: '<%= pkg.buildPath %>/scripts/purify.min.js'},
{src: '<%= pkg.libPath %>/timeago.js/dist/timeago.full.min.js', dest: '<%= pkg.buildPath %>/scripts/timeago.full.min.js'},
]
}
},
"string-replace": {
keys: {
files: {
"<%= pkg.buildPath %>/scripts/core.js": "<%= pkg.buildPath %>/scripts/core.js"
},
options: {
replacements: [
{
pattern: 'clientSecret: ""',
replacement: 'clientSecret: "' + grunt.option("clientSecret") + '"'
},
{
pattern: 'clientId: ""',
replacement: 'clientId: "' + grunt.option("clientId") + '"'
}
]
}
},
sandboxApi: {
files: {
"<%= pkg.buildPath %>/scripts/feedly.api.js": "<%= pkg.buildPath %>/scripts/feedly.api.js"
},
options: {
replacements: [
{
pattern: /http(?:s)?:\/\/(?:www\.)?cloud\.feedly\.com/gi,
replacement: "https://sandbox7.feedly.com"
}
]
}
},
sandboxLink: {
files: {
"<%= pkg.buildPath %>/scripts/core.js": "<%= pkg.buildPath %>/scripts/core.js"
},
options: {
replacements: [
{
pattern: /http(?:s)?:\/\/(?:www\.)?feedly\.com/gi,
replacement: "https://sandbox7.feedly.com"
},
{
pattern: /let\s+redirectUri\s+=\s+[^;]*/gi,
replacement: "let redirectUri = 'http://localhost'"
}
]
}
}
},
uglify: {
dist: {
files: {
"<%= pkg.buildPath %>/scripts/core.js": ["<%= pkg.buildPath %>/scripts/core.js"],
"<%= pkg.buildPath %>/scripts/feedly.api.js": ["<%= pkg.buildPath %>/scripts/feedly.api.js"],
"<%= pkg.buildPath %>/scripts/options.js": ["<%= pkg.buildPath %>/scripts/options.js"],
"<%= pkg.buildPath %>/scripts/popup.js": ["<%= pkg.buildPath %>/scripts/popup.js"]
}
}
},
zip: {
build: {
cwd: "<%= pkg.buildPath %>/",
src: ["<%= pkg.buildPath %>/**"],
dest: '<%= pkg.buildPath %>/feedly-notifier-' + grunt.option('browser') + '.zip',
compression: 'DEFLATE'
}
},
clean: {
"pre-build": ["<%= pkg.buildPath %>"],
build: {
files: [
{expand: true, cwd: "<%= pkg.buildPath %>", src: ["*", "!*.zip"]}
]
}
},
preprocess: {
js: {
files: [
{src: ["<%= pkg.buildPath %>/scripts/*.js"]},
{src: ["<%= pkg.buildPath %>/*.json"]}
],
options: {
inline: true,
context: {
BROWSER: grunt.option("browser")
},
type: "js"
}
},
html: {
files: [
{src: ["<%= pkg.buildPath %>/*.html"]}
],
options: {
inline: true,
context: {
BROWSER: grunt.option("browser")
}
}
}
}
});
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-zip');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-preprocess');
grunt.registerTask("build", ["clean:pre-build", "copy", "string-replace:keys", "preprocess", "zip", "clean:build"]);
grunt.registerTask("sandbox", ["copy", "string-replace", "preprocess"]);
grunt.registerTask("default", ["copy", "string-replace:keys", "preprocess"]);
};