-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
executable file
·134 lines (131 loc) · 3.99 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
clean: {
www: "build/www",
srv: ["build/srv", "build/node_modules", "build/config.json", "build/package.json", "build/index.js", "build/lib" ],
tmp: "_tmp",
},
concat: {
www: {
files: {
"_tmp/lib/data-widgets.js": ["lib/client/ui/data-widgets-js/DataWidgets.js", "lib/client/ui/data-widgets-js/WidgetContainer.js", "lib/client/ui/data-widgets-js/GaugeWidget.js", "lib/client/ui/data-widgets-js/BarWidget.js", "lib/client/ui/data-widgets-js/GraphWidget.js", ],
"_tmp/lib/info-widgets.js": ["lib/client/ui/info-widgets-js/InfoWidgets.js", "lib/client/ui/info-widgets-js/WeatherWidget.js", ],
"_tmp/lib/time-utils.js": ["lib/client/time-utils-js/Time.js"],
"_tmp/lib/solarboard-client.js": ["lib//client/api/solar-board-client-js/SolarBoard.js", "lib//client/api/solar-board-client-js/SolarBoardClient.js"],
},
},
},
replace: {
www: {
options: {
patterns: [
{
match: "SITE_ID",
replace: grunt.file.readJSON("_config.json").sites[0].id,
},
],
},
files: [
{
src: "client/src/js/app.js",
dest: "_tmp/app.js",
},
],
},
},
uglify: {
www: {
files: {
"build/www/lib/bundle.min.js": ["_tmp/lib/time-utils.js", "_tmp/lib/data-widgets.js", "_tmp/lib/info-widgets.js", "_tmp/lib/solarboard-client.js",],
"build/www/app.min.js": ["_tmp/app.js", "client/src/js/view.js", "client/src/js/start.js",],
},
},
},
copy: {
srv: {
files: [{
expand: true,
cwd: "lib/srv/",
src: "*.js",
dest: "build/lib/",
},{
expand: true,
src: "package.json",
dest: "build/",
},{
expand: true,
cwd: "srv/src/",
src: "index.js",
dest: "build/",
},{
expand: true,
src: "_config.json",
dest: "build/",
rename: function(dest, src) {
return dest + src.replace("_", "");
},
}],
},
www: {
files: [{
expand: true,
cwd: "client/src/html/",
src: "index.html",
dest: "build/www/",
}, {
expand: true,
cwd: "client/src/css/",
src: "app.css",
dest: "build/www/res/css",
}, {
expand: true,
cwd: "lib/client/ui/data-widgets-js/css/",
src: "data-widgets-js.css",
dest: "build/www/lib",
}, {
expand: true,
cwd: "lib/client/ui/data-widgets-js/icons/",
src: "*.ttf",
dest: "build/www/lib",
},{
expand: true,
cwd: "lib/client/ui/info-widgets-js/css/",
src: "info-widgets-js.css",
dest: "build/www/lib",
}, {
expand: true,
cwd: "lib/client/ui/info-widgets-js/icons/",
src: "*.png",
dest: "build/www/lib",
}, {
expand: true,
cwd: "lib/client/ui/info-widgets-js/fonts/",
src: "*.ttf",
dest: "build/www/lib",
},{
expand: true,
cwd: "_dependencies/",
src: "Chart.bundle.min.js",
dest: "build/www/lib",
},]
},
},
exec: {
srv: {
cwd: "build/",
cmd: "npm install --only=production",
},
},
});
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-replace");
grunt.loadNpmTasks("grunt-exec");
grunt.registerTask("www", function() {
grunt.task.run("clean:www", "concat:www", "replace:www", "uglify:www", "copy:www", "clean:tmp");
});
grunt.registerTask("srv", ["clean:srv", "copy:srv", "exec:srv" ]);
};