forked from yurychika/aui-gridx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
147 lines (125 loc) · 3.56 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
"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 = "./out/";
// The grunt.config property populated by amdserialize, containing the
// list of files to include in the layer.
var outprop = "amdoutput";
var allI18nFiles = expandFiles( "i18n/*.js" );
// var jquery_ui = expandFiles('jquery-ui/ui/jquery-ui.js')
// console.log(allI18nFiles);
// console.log(grunt.file.expandMapping( "jquery-ui/ui/i18n/*.js" ));
function expandFiles( files ) {
return grunt.util._.pluck( grunt.file.expandMapping( files ), "src" ).map(function( values ) {
return values[ 0 ];
});
}
// console.log(allI18nFiles);
grunt.initConfig({
concat: {
//i18n for dialog
release: {
src: [
'src/js/bootstrap.js',
'src/js/core/directives/*.js',
'src/js/core/factories/*.js',
'src/js/core/factories/model/*.js',
'src/js/core/core.js',
'src/js/core/services/*.js',
'release/.tmp/template.js'
],
dest: 'release/build.js',
},
},
ngtemplates: {
'aui-grid': {
// Look for templates in src and in feature template directories
src: ['src/templates/**/*.html'],
dest: 'release/.tmp/template.js',
options: {
module: 'aui.grid',
htmlmin: { collapseWhitespace: true, collapseBooleanAttributes: true },
// Strip .html extension
url: function(url) {
// Remove the src/templates/ prefix
url = url.replace(/^src\/templates\//, '');
// Replace feature prefix with just 'ui-grid'
url = url.replace(/^src\/features\/[^\/]+?\/templates/, 'ui-grid');
// Remove the .html extension
return url.replace('.html', '');
}
}
}
},
// The loader config should go here.
amdloader: {
// Here goes the config for the amd plugins build process.
config: {
// baseUrl: "/",
// paths: {
// "hello": "hello"
// },
// text should be replace by the module id of text plugin
text: {
inlineText: true
},
// i18n should be replace by the module id of i18n plugin
i18n: {
localesList: ["fr"]
}
}
},
// Copy the plugin files to the real output directory.
copy: {
image: {
expand: true,
cwd: 'themes/less/',
src: [
'images/*',
'dthink.css',
'dthink-a11y.css',
'dthink-rtl.css',
'dthink.less',
'blue-theme.less'
],
// flatten: true,
dest: 'release/themes/dthink'
},
},
// Erase temp directory and previous build
clean: {
erase: [outdir],
finish: [tmpdir]
}
});
// 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("concat");
grunt.task.run("copy");
});
});
// Load the plugin that provides the "amd" task.
require( "load-grunt-tasks" )( grunt );
// grunt.loadTasks( "build/task" );
// Load vendor plugins.
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks('grunt-angular-templates');
// grunt.loadNpmTasks('grunt-contrib-clean');
// grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask( "js", [
"build:*:*",
"concat:jquery_ui",
"concat:i18n",
"concat:jquery_i18n"
]);
grunt.registerTask( "css", ["copy"] );
// Default task.
grunt.registerTask("default", ["ngtemplates", "concat"]);
};