forked from robertd/esri-jsapi-rjs-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
101 lines (96 loc) · 2.78 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
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.initConfig({
requirejs: {
// configuration for a multi-file build
compile: {
options: {
baseUrl: '.',
appDir: 'src',
dir: 'dist',
paths: {
'esri': 'empty:',
'dojo': 'empty:',
'dojox': 'empty:',
'dijit': 'empty:'
},
optimize: 'uglify2'
}
},
// configuration for a single-file build
single: {
options: {
baseUrl: 'src/js',
name: 'main',
out: 'dist/js/main-built.js',
paths: {
'esri': 'empty:',
'dojo': 'empty:',
'dojox': 'empty:',
'dijit': 'empty:',
'text': '../../deps/text/text',
'domReady': '../../deps/domReady/domReady',
'i18n': '../../deps/i18n/i18n'
},
exclude: ['esri', 'dojo', 'dojox', 'dijit', 'text', 'domReady', 'i18n'],
inlineText: true,
// NOTE: this does not work
// locale: "es",
optimize: 'uglify2'
}
},
// used in single file build to optimize static resources such as css images
css: {
options: {
cssIn: 'src/css/app.css',
out: 'dist/css/app.css'
}
}
},
replace: {
// needed for inlined templated in single-file build
"main-built": {
src: ['dist/js/main-built.js'],
dest: 'dist/js/main-built.js',
replacements: [{
from: 'text!',
to: ''
}]
},
// replace reference to main file for single file build
index: {
src: ['src/index.html'],
dest: 'dist/index.html',
replacements: [{
from: 'js/main.js',
to: 'js/main-built.js'
},
// set locale to test i18n
{
from: '// locale:',
to: 'locale:'
}]
}
},
// needed for single file build
clean: {
single: ['dist']
},
copy: {
// needed for single file build
single: {
files: [
// single file build doesn't copy over nls
{expand: true, cwd: 'src/js/app/wijit/', src:['nls/**'], dest: 'dist/js/app/wijit/'},
// r.js doesn't copy background image paths that it traces through url()
{expand: true, cwd: 'src/js/app/wijit/resources/', src:['img/**'], dest: 'dist/js/app/wijit/resources/'}
]
}
}
});
grunt.registerTask("compile", ["requirejs:compile"]);
grunt.registerTask("single", ["clean", "requirejs:single", "replace", "requirejs:css", "copy"]);
};