-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGruntfile.js
109 lines (103 loc) · 4.21 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
module.exports = function (grunt) {
var pkg = grunt.file.readJSON("package.json");
grunt.initConfig({
pkgName: pkg.name,
name: pkg.name,
watch: {
autoDeployUpdate: {
"files": [ "./src/**/*" ],
"tasks": [ "copy:out", "compress", "copy:deployment", "copy:mpks" ],
options: {
debounceDelay: 250,
livereload: true
}
}
},
compress: {
out: {
options: {
archive: "./dist/" + pkg.version + "/" + pkg.name + ".mpk",
mode: "zip"
},
files: [ {
expand: true,
date: new Date(),
store: false,
cwd: "./out",
src: [ "**/*" ]
} ]
}
},
copy: {
out: {
files: [
{ dest: "./out", cwd: "./src/", src: [ "**/*", "!**/*.psd" ], expand: true }
]
},
deployment: {
files: [
{ dest: "./test/Mx5.16.1/deployment/web/widgets", cwd: "./out/", src: [ "**/*" ], expand: true },
{ dest: "./test/Mx5.21/deployment/web/widgets", cwd: "./out/", src: [ "**/*" ], expand: true },
{ dest: "./test/Mx7.0.2/deployment/web/widgets", cwd: "./out/", src: [ "**/*" ], expand: true }
]
},
mpks: {
files: [
{ dest: "./test/Mx5.16.1/widgets", cwd: "./dist/" + pkg.version + "/", src: [ pkg.name + ".mpk" ], expand: true },
{ dest: "./test/Mx5.21/widgets", cwd: "./dist/" + pkg.version + "/", src: [ pkg.name + ".mpk" ], expand: true },
{ dest: "./test/Mx7.0.2/widgets", cwd: "./dist/" + pkg.version + "/", src: [ pkg.name + ".mpk" ], expand: true }
]
}
},
clean: {
build: [
"./dist/" + pkg.version + "/" + pkg.name + "/*",
"./test/Mx5.16.1/deployment/web/widgets/" + pkg.name + "/*",
"./test/Mx5.16.1/widgets/" + pkg.name + ".mpk",
"./test/Mx5.21/deployment/web/widgets/" + pkg.name + "/*",
"./test/Mx5.21/widgets/" + pkg.name + ".mpk",
"./test/Mx7.0.2/deployment/web/widgets/" + pkg.name + "/*",
"./test/Mx7.0.2/widgets/" + pkg.name + ".mpk"
],
out: "./out/**/*"
},
file_append: {
fixMendix: {
files: [
{
append: '\n require(["<%=pkgName%>/widget/<%=name%>"]);',
input: "src/<%=pkgName%>/widget/<%=name%>.js",
output: "out/<%=pkgName%>/widget/<%=name%>.js"
}
]
}
},
uglify: {
distribute: {
options: {
sourceMap: true,
sourceMapIncludeSources: true,
banner: "// " + pkg.name + " V" + pkg.version + ' Date : <%= grunt.template.today("isoDateTime") %> Copyright: " + pkg.copyright'
},
files: {
// Mendix quirck, add Fix at and end of fine.
"out/<%=pkgName%>/widget/<%=name%>.js": [ "src/<%=pkgName%>/widget/<%=name%>.js" ]
}
}
}
});
grunt.loadNpmTasks("grunt-contrib-compress");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-file-append");
grunt.registerTask("default", [ "clean build", "watch" ]);
grunt.registerTask("distribute", [ "clean:out", "copy:out", "uglify", "compress", "copy:mpks", "copy:mpks", "copy:deployment" ]);
grunt.registerTask(
"clean build",
"Compiles all the assets and copies the files to the build directory.",
[ "clean", "copy:out", "compress", "copy:mpks" ]
);
grunt.registerTask("build", [ "clean build" ]);
};