-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
98 lines (86 loc) · 3.12 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
const sass = require('node-sass');
module.exports = function(grunt) {
let settings = grunt.file.readJSON("build-settings.json");
settings.version = grunt.file.readJSON("package.json").version;
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
sass: {
options: {
implementation: sass,
sourcemap: "none"
},
default: {
files: {
"dest/css/common.css": "dest/sass/common.sass",
"dest/css/options.css": "dest/sass/options.sass"
}
}
},
clean: {
dest: ["dest/"],
sass: ["dest/sass"]
},
copy: {
"src-to-dest": {
expand: true,
cwd: "src",
src: ["**/*.*", "!firefox-overrides/**", "!chrome-overrides/**"],
dest: "dest/"
},
"firefox-overrides": {
expand: true,
cwd: "src/firefox-overrides",
src: ["**/*.*"],
dest: "dest/"
},
"chrome-overrides": {
expand: true,
cwd: "src/chrome-overrides",
src: ["**/*.*"],
dest: "dest/"
}
},
"string-replace": (() => {
let ret = {};
for(let name in settings.browsers){
ret[name] = {
files: {
"dest/": ["dest/**/*.html", "dest/**/*.json", "dest/**/*.sass"]
},
options: {
replacements: [{
pattern: /<%=(.*?)%>/ig,
replacement(match, p1){
return settings.browsers[name][p1.trim()] || settings[p1.trim()] || "";
}
}]
}
};
}
return ret;
})(),
watch: { // Compile everything into one task with Watch Plugin
chrome: {
files: "src/**/*.*",
tasks: ["build-chrome"]
},
firefox: {
files: "src/**/*.*",
tasks: ["build-firefox"]
}
}
});
// Load Grunt plugins
grunt.loadNpmTasks("grunt-sass");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-string-replace");
// Default task(s).
grunt.registerTask("build-chrome", ["clean:dest", "copy:src-to-dest", "string-replace:chrome", "sass", "clean:sass", "copy:chrome-overrides"]);
grunt.registerTask("build-firefox", ["clean:dest", "copy:src-to-dest", "string-replace:firefox", "sass", "clean:sass", "copy:firefox-overrides"]);
grunt.registerTask("watch-chrome", ["build-chrome", "watch:chrome"]);
grunt.registerTask("watch-firefox", ["build-firefox", "watch:firefox"]);
grunt.registerTask("default", ["watch-chrome"]);
};