-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathGruntfile.js
162 lines (155 loc) · 5.24 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
var package_json = require(__dirname+"/package.json");
var bundleFiles=[
"openNote.bundle.*",
"webpack_files/**/*.*",
"openNote/**/*.html"
];
// Helper function
var serverConfig = function(keepalive){
if(keepalive==undefined)
keepalive = true;
return {
options: {
port: 8080,
base: ".",
keepalive: keepalive
}
};
};
module.exports = function(grunt) {
//Initializing the configuration object
grunt.initConfig({
connect: {
server: serverConfig(),
serverNoAlive: serverConfig(false)
},
compress: {
main: {
options: {
archive: "dist/"+package_json.version+".zip"
},
files: [{
src: [
"openNote.appcache",
"index.html",
].concat(bundleFiles),
expand: true
}]
}
},
jshint: {
options: {
"esversion":6,
},
all: ["openNote/**/*.js*", //Order matters
"!node_modules/**",
"!OpenNote/node_moduless/**"
]
},
//Style
less: {
devDark: {
options: {
paths: ["assets/css"],
modifyVars: {
offset: "#000000"
}
},
files: {
"openNote/style/invert/dark/style.css": "openNote/style/invert/style.less",
"openNote/style/invert/dark/alertify.css": "openNote/style/invert/alertify.less"
}
},
devLight: {
options: {
paths: ["assets/css"],
modifyVars: {
offset: "#FFFFFF"
}
},
files: {
"openNote/style/invert/light/style.css": "openNote/style/invert/style.less",
"openNote/style/invert/light/alertify.css": "openNote/style/invert/alertify.less"
}
},
prodDark: {
options: {
paths: ["assets/css"],
cleancss: true,
modifyVars: {
offset: "#000000"
}
},
files: {
"openNote/style/invert/dark/style.css": "openNote/style/invert/style.less",
"openNote/style/invert/dark/alertify.css": "openNote/style/invert/alertify.less"
}
},
prodLight: {
options: {
paths: ["assets/css"],
cleancss: true,
modifyVars: {
offset: "#FFFFFF"
}
},
files: {
"openNote/style/invert/light/style.css": "openNote/style/invert/style.less",
"openNote/style/invert/light/alertify.css": "openNote/style/invert/alertify.less"
}
}
},
shell: {
clean: {
command: ["rm -rf dist webpack_files",
"cd openNote/style/invert/",
"rm -rf dark light",
].join("&&")
},
test: {
command: ["npm run test"].join("&&")
},
dev: {
command: ["npm run dev"].join("&&")
},
build: {
command: ["npm run build"].join("&&")
}
},
//HTML 5
manifest: {
generate: {
options: {
basePath: ".",
exclude: ["openNote.appcache"],
verbose: true,
timestamp: true,
hash: true,
master: ["index.html"]
},
src: bundleFiles,
dest: "openNote.appcache"
}
}
});
//Plugin loading
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-less");
grunt.loadNpmTasks("grunt-shell");
grunt.loadNpmTasks("grunt-manifest");
grunt.loadNpmTasks("grunt-contrib-compress");
grunt.loadNpmTasks("grunt-contrib-connect");
//Task definition
//css
grunt.registerTask("buildDevCSS", ["less:devDark", "less:devLight"]);
grunt.registerTask("buildProdCSS", ["less:prodDark", "less:prodLight"]);
//deployment
// you can run individual command using the plug-in command syntax suck as manifest:generate or shell:clean
grunt.registerTask("build", ["buildDevCSS", "shell:build", "manifest:generate"]);
grunt.registerTask("buildProd", ["buildProdCSS", "shell:build", "manifest:generate"]);
grunt.registerTask("default", ["build", "shell:dev"]);
grunt.registerTask("deploy", ["shell:clean", "buildProd", "compress"]);
grunt.registerTask("testDeploy", ["shell:clean", "buildProd", "connect:server"]);
//testing
grunt.registerTask("ci", "Build the app and runs tests on it", ["jshint:all", "buildProd", "connect:serverNoAlive", "shell:test" ]);
};