-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
179 lines (178 loc) · 6.36 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
module.exports = function (grunt) {
grunt.initConfig({
"pkg": grunt.file.readJSON("package.json"),
"meta": {
"paths": {
"source": "Source",
"styles": "Styles",
"build": "Build",
"dist": "Distribution"
}
},
"tslint": {
"default": {
"options": {
"configuration": grunt.file.readJSON("tslint.json")
},
"files": {
"src": [
"<%= meta.paths.source %>/*.ts",
"<%= meta.paths.source %>/*.tsx",
"<%= meta.paths.source %>/Components/**/*.tsx"
]
}
}
},
"clean": {
"prebuild": [
"<%= meta.paths.dist %>",
"<%= meta.paths.build %>",
"<%= meta.paths.source %>/<%= meta.paths.styles %>/**/*.css"
],
"postbuild": [
"<%= meta.paths.dist %>/<%= pkg.name %>.js",
"<%= meta.paths.build %>"
]
},
"copy": {
"prebuild": {
"files": [{
"src": "<%= meta.paths.source %>/*.ts",
"dest": "<%= meta.paths.build %>/",
"expand": true,
"flatten": true
}, {
"src": "<%= meta.paths.source %>/*.tsx",
"dest": "<%= meta.paths.build %>/",
"expand": true,
"flatten": true
}, {
"src": "<%= meta.paths.source %>/<%= pkg.name %>.tsx",
"dest": "<%= meta.paths.build %>/",
"expand": true,
"flatten": true,
"rename": function (dest, src) {
return dest + "/<%= pkg.name %>-<%= pkg.version %>.tsx";
}
}, {
"src": "<%= meta.paths.source %>/References/*.ts",
"dest": "<%= meta.paths.build %>",
"expand": true,
"flatten": true
}, {
"src": "<%= meta.paths.source %>/References/*.?s",
"dest": "<%= meta.paths.dist %>/",
"expand": true,
"flatten": true
}, {
"src": "README.md",
"dest": "<%= meta.paths.dist %>/"
}, {
"src": "LICENSE.txt",
"dest": "<%= meta.paths.dist %>/"
}]
},
"distribution": {
"files": [{
"src": "<%= meta.paths.source %>/<%= pkg.name %>.js",
"dest": "<%= meta.paths.dist %>/<%= pkg.name %>-<%= pkg.version %>.js"
}]
}
},
"less": {
"source": {
"options": {
"paths": ["<%= meta.paths.source %>/<%= pkg.styles %>"]
},
"files": [{
"expand": true,
"cwd": "<%= meta.paths.source %>/<%= meta.paths.styles %>",
"src": ["**/*.less"],
"dest": "<%= meta.paths.source %>/<%= meta.paths.styles %>",
"ext": ".css"
}]
},
"distribution": {
"options": {
"paths": ["<%= meta.paths.source %>/<%= pkg.styles %>"]
},
"files": [{
"<%= meta.paths.dist %>/styles.css": "<%= meta.paths.source %>/<%= meta.paths.styles %>/**/*.less"
}]
}
},
"preprocess": {
"default": {
"src": "<%= meta.paths.build %>/<%= pkg.name %>.tsx",
"dest": "<%= meta.paths.dist %>/<%= pkg.name %>-<%= pkg.version %>.tsx"
}
},
"typescript": {
"source": {
"src": [
"Source/**/*.ts",
"Source/**/*.tsx"
],
"options": {
"jsx": "react",
"sourceMap": true
}
},
"distribution": {
"src": [
"<%= meta.paths.source %>/<%= pkg.name %>.ts",
"<%= meta.paths.source %>/<%= pkg.name %>.tsx"
],
"dest": "<%= meta.paths.dist %>/<%= pkg.name %>-<%= pkg.version %>.js",
"options": {
"jsx": "react",
"sourceMap": true
}
},
"watch": {
"src": [
"<%= meta.paths.source %>/**/*.ts",
"<%= meta.paths.source %>/**/*.tsx"
],
"options": {
"jsx": "react",
"sourceMap": true,
"watch": [
"<%= meta.paths.source %>/**/*.ts",
"<%= meta.paths.source %>/**/*.tsx"
]
}
}
},
"uglify": {
"options": {
"compress": true,
"sourceMap": true
},
"default": {
"files": {
"<%= meta.paths.dist %>/<%= pkg.name %>-<%= pkg.version %>.min.js": [
"<%= meta.paths.dist %>/<%= pkg.name %>-<%= pkg.version %>.js"
]
}
}
},
"mocha_phantomjs": {
"default": ["Tests/*.html"]
}
});
grunt.loadNpmTasks("grunt-tslint");
grunt.loadNpmTasks("grunt-contrib-clean");
grunt.loadNpmTasks("grunt-contrib-copy");
grunt.loadNpmTasks("grunt-preprocess");
grunt.loadNpmTasks("grunt-typescript");
grunt.loadNpmTasks("grunt-contrib-less");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-mocha-phantomjs");
grunt.registerTask("default", [
"tslint", "clean", "copy:prebuild", "preprocess", "typescript:source", "less:source", "copy:distribution", "typescript:distribution", "less:distribution", "clean:postbuild", "uglify", "mocha_phantomjs"
]);
grunt.registerTask("watch", [
"typescript:watch"
]);
};