-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
154 lines (131 loc) · 3.8 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
"use strict";
module.exports = function (grunt) {
// A temporary directory used by amdserialize to output the processed modules.
var tmpdir = "tmp/";
// The final output directory.
var outdir = "build/";
// The grunt.config property populated by amdserialize, containing the
// list of files to include in the layer.
var outprop = "amdoutput";
grunt.initConfig({
// The loader config should go here.
amdloader: {
// Everything should be relative to baseUrl
baseUrl: "./bower_components/",
paths: {
angular: 'angular/angular',
},
shim: {
'angular' : {'exports' : 'angular'},
},
map: {
jquery: {
"jquery/src/selector": "jquery/src/selector-native"
}
},
// Enable build of requirejs-text/text
inlineText: true,
// Here goes the config for the amd plugins build process (has, i18n, ecma402...).
config: {}
},
// The common build config
amdbuild: {
// dir is the output directory.
dir: tmpdir,
// List of plugins that the build should not try to resolve at build time.
runtimePlugins: [],
// List of layers to build.
layers: [{
name: "dependencies.build",
include: [
// Modules and layers listed here, and their dependencies, will be added to the layer.
// Modules and layers listed here, and their dependencies, will be added to the layer.
"delite/register",
"deliteful/list/List",
"angular-delite/wrappers/widget",
"angular-delite/dstore/TrackableRest",
"dojo/request/xhr",
"dojo/selector/_loader",
"requirejs-text/text",
"deliteful/ProgressIndicator",
],
includeShallow: [
// Only the modules listed here (ie. NOT their dependencies) will be added to the layer.
],
exclude: [
// Modules and layers listed here, and their dependencies, will NOT be in the layer.
"angular"
],
excludeShallow: [
// Only the modules listed here (ie. NOT their dependencies) will NOT be in the layer.
]
}]
},
// Config to allow uglify to generate the layer.
uglify: {
options: {
banner: "<%= " + outprop + ".header%>",
sourceMap: false
},
dist: {
src: "<%= " + outprop + ".modules.abs %>",
dest: outdir + "<%= " + outprop + ".layerPath %>",
options: {
mangle: false,
beautify: false
}
},
},
// Copy the plugin files to the real output directory.
copy: {
plugins: {
expand: true,
cwd: tmpdir,
src: "<%= " + outprop + ".plugins.rel %>",
dest: outdir,
dot: true
},
notIncludedModules: {
expand: false,
src: ["./bower_components/angular/**", "./style.css", "./app.js"],
dest:outdir,
dot: true
}
},
// Erase previous build.
clean: {
erase: [outdir]
},
jshint: {
src: [
"app.js",
// Note: skip this file since it gives a JSHint error about a character being silently deleted.
// It will have to be fixed by the translators.
"!nls/he/loading.js"
],
options: {
jshintrc: ".jshintrc"
}
}
});
// The main build task.
grunt.registerTask("amdbuild", function (amdloader) {
var name = this.name,
layers = grunt.config(name).layers;
layers.forEach(function (layer) {
grunt.task.run("amddepsscan:" + layer.name + ":" + name + ":" + amdloader);
grunt.task.run("amdserialize:" + layer.name + ":" + name + ":" + outprop);
grunt.task.run("uglify");
grunt.task.run("copy:plugins");
});
});
// Load the plugin that provides the "amd" task.
grunt.loadNpmTasks("grunt-amd-build");
// Load vendor plugins.
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks("grunt-contrib-jshint");
// Default task.
grunt.registerTask("build", ["clean:erase", "amdbuild:amdloader", "amdreportjson:amdbuild", "copy:notIncludedModules"]);
};