This repository has been archived by the owner on Sep 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
135 lines (125 loc) · 4.04 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
module.exports = function (grunt) {
// Setup default url for the irma api server url.
// These are used to configure the examples (so they can find the authentication server)
var api_server_url;
if (typeof(grunt.option("api_server_url")) === "undefined") {
console.log("INFO: set api_server_url to have working local phone examples");
}
api_server_url = grunt.option("api_server_url") || "https://demo.irmacard.org/tomcat/irma_api_server/api/v2/";
var client = grunt.option("client") || false;
var examples = grunt.option("examples") || false;
if (!client && !examples) {
console.log("INFO: building everything");
client = examples = true;
}
console.log("Api server url:", api_server_url);
var tasks = [];
var watchTasks = {};
if (client) {
tasks.push("browserify:client", "uglify", "sass");
watchTasks.clientScripts = {
files: ["./client/**/*.js"],
tasks: ["browserify:client", "uglify"],
};
watchTasks.sass = {
files: ["./client/**/*.scss"],
tasks: ["sass"],
};
}
if (examples) {
tasks.push("copy:examples", "string-replace", "copy:components");
watchTasks.htmlfiles = {
files: [ "./examples/**/*.html" ],
tasks: ["copy"],
};
watchTasks.exampleScripts = {
files: ["./examples/*.js"],
tasks: ["string-replace"],
};
}
var replacements = [{
pattern: "<IRMA_API_SERVER>",
replacement: api_server_url,
}];
grunt.initConfig({
browserify: {
options: {
transform: [
[
"babelify",
{
presets: ["es2015"],
},
],
],
},
client: {
options: {
browserifyOptions: {
standalone: "IRMA",
},
},
files: {
"./build/client/irma.js": ["./client/irma.js"],
},
},
},
uglify: {
client: {
files: {
"./build/client/irma.min.js": ["./build/client/irma.js"],
},
},
},
sass: {
options: {
sourcemap: false,
compress: false,
yuicompress: false,
style: "expanded",
includePaths: ["node_modules/compass-mixins/lib"],
},
client: {
files: {
"./build/client/irma.css": "client/sass/irma.scss",
}
},
},
copy: {
// Copying the node_modules is a bit of a hack
components: {
cwd: "node_modules",
src: ["bootstrap/**/*", "jquery/**/*", "jwt-decode/**/*", "handlebars/**/*"],
dest: "build/components",
expand: "true",
},
examples: {
cwd: "examples",
src: ["**/*", "!**/*.js"],
dest: "build/examples",
expand: "true",
},
},
"string-replace": {
examples: {
files: [{
cwd: "./",
src: ["examples/**/*.js"],
dest: "build/",
expand: "true",
}],
options: { replacements: replacements },
},
},
watch: watchTasks,
});
grunt.loadNpmTasks("grunt-browserify");
grunt.loadNpmTasks("grunt-babel");
grunt.loadNpmTasks("grunt-sass");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-string-replace");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.registerTask("default", ["build", "watch"]);
grunt.registerTask("build", tasks);
};