-
Notifications
You must be signed in to change notification settings - Fork 7
/
Gruntfile.js
123 lines (110 loc) · 3.62 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
var fs = require('fs'),
path = require('path');
function isEmptyDirectory (filepath) {
var children, x;
if (!fs.statSync(filepath).isDirectory()) {
return false;
}
children = fs.readdirSync(filepath);
for (x in children) {
if (!isEmptyDirectory(path.join(filepath, children[x]))) {
return false;
}
}
return true;
}
module.exports = function (grunt) {
// Build customizations would be left up to developer to implement.
grunt.loadNpmTasks('grunt-dojo');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-strip-code');
grunt.initConfig({
strip_code: {
options: {
blocks: [{
start_block: '<!--debug-start-->',
end_block: '<!--debug-end-->'
}, {
start_block: '/* debug-start */',
end_block: '/* debug-end */'
}]
},
your_target: {
src: 'dist/dojoConfig.js'
}
},
clean: {
build: {
src: ['dist/']
},
uncompressed: {
src: [
'dist/**/*.uncompressed.js'
]
},
afterbuild: {
src: [
//lets delete everything!
'dist/**/*',
//...except a few things
'!dist/index.html',
'!dist/dojoConfig.js',
//dojo built layers and css files
//include other layers, or they'll be deleted
'!dist/dojo/dojo.js',
'!dist/app/css/build.css',
//the build output in case something goes wrong
'!dist/build-report.txt',
//any additional configs
//'!dist/**/app/config/**/*.js',
//images, resources, and source maps
'!dist/**/fonts/**',
'!dist/**/images/**',
'!dist/**/resources/**',
'!dist/**/*.js.map',
// i18n
'!dist/**/nls/*.js',
'dist/**/nls/*.consoleStripped.js',
'dist/**/nls/*.uncompressed.js',
'!dist/moment/locale/**',
// flags
'!dist/**/flags/**/**'
],
filter: 'isFile'
},
emptydir: {
src: ['dist/**/*'],
filter: isEmptyDirectory
}
},
copy: {
main: {
files: [{
expand: true,
cwd: 'src/',
src: ['index.html', 'dojoConfig.js'],
dest: './dist/'
}]
}
},
dojo: {
travis: {
options: {
profile: 'profiles/travis.profile.js'
}
},
options: {
releaseDir: '../dist',
profile: 'profiles/build.profile.js',
dojo: 'src/dojo/dojo.js',
load: 'build',
cwd: './',
basePath: './src'
}
}
});
grunt.registerTask('build-dev', ['clean:build', 'dojo', 'copy']);
grunt.registerTask('build-travis', ['clean:build', 'dojo:travis']);
grunt.registerTask('build', ['clean:build', 'dojo', 'copy', 'clean:afterbuild', 'clean:emptydir', 'strip_code']);
};