-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
121 lines (108 loc) · 4.25 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
module.exports = function (grunt) {
"use strict";
grunt.initConfig(
{
pkg: grunt.file.readJSON('package.json'),
requirejs: {
compile: {
options: {
baseUrl: 'build/generated',
mainConfigFile: 'build/generated/build.js',
name: '../../lib/components/almond/almond',
out: 'build/generated/<%= pkg.name %>.js',
optimize: 'none'
}
}
},
typescript: {
base: {
src: ['src/main/ts/**/*.ts'],
dest: 'build/generated',
options: {
module: 'amd',
target: 'es5',
rootDir: 'src/main/ts/',
sourceMap: false,
declaration: false
}
}
},
closurecompiler: {
minify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
language_in: 'ECMASCRIPT5',
language_out: 'ECMASCRIPT5'
},
files: {
// 'dest' : 'source'
'build/target/<%= pkg.name %>.min.js': 'build/generated/<%= pkg.name %>.js'
}
},
minify_3rd_party_libs: {
files: {
// 'dest' : 'source'
'build/target/lib/components/keymaster/keymaster.min.js': 'build/target/lib/components/keymaster/keymaster.js',
'build/target/lib/components/underscore/underscore.min.js': 'build/target/lib/components/underscore/underscore.js'
}
}
},
cssmin: {
minify: {
expand: true,
src: ['css/*.css', '!css/*.min.css'],
dest: 'build/target',
ext: '.css'
}
},
copy: {
js_to_generated_js: {
files: [
{expand: true, cwd: 'src/main/js', src: ['**/*.js'], dest: 'build/generated', filter: 'isFile'}
]
},
css_files: {
files: [
{expand: true, src: ['css/*'], dest: 'build/target', filter: 'isFile'}
]
},
static_resources: {
files: [
{expand: true, src: ['lib/*.js'], dest: 'build/target', filter: 'isFile'},
{expand: true, src: ['lib/components/**/dist/*.js'], dest: 'build/target', filter: 'isFile'},
{expand: true, src: ['lib/components/underscore/*.js'], dest: 'build/target', filter: 'isFile'},
{expand: true, src: ['lib/components/keymaster/*.js'], dest: 'build/target', filter: 'isFile'},
{expand: true, src: ['img/*'], dest: 'build/target', filter: 'isFile'},
{expand: true, cwd: 'src/main/html', src: ['*.html'], dest: 'build/target', filter: 'isFile'},
]
},
js_to_min_js: {
files: [
{src: 'build/generated/<%= pkg.name %>.js', dest: 'build/target/<%= pkg.name %>.min.js'},
{src: 'build/target/lib/components/keymaster/keymaster.js', dest: 'build/target/lib/components/keymaster/keymaster.min.js'},
{src: 'build/target/lib/components/underscore/underscore.js', dest: 'build/target/lib/components/underscore/underscore.min.js'}
]
}
},
watch: {
src: {
files: ['src/main/js/**/*.js', 'src/main/ts/**/*.ts', 'src/main/html/**', 'css/**', 'img/**', 'lib/**'],
tasks: ['no-uglify']
}
},
clean: {
build: ['build']
}
});
// Register tasks
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-typescript');
grunt.loadNpmTasks('grunt-closurecompiler');
// Default task(s).
grunt.registerTask('default', ['typescript', 'copy:js_to_generated_js', 'requirejs', 'closurecompiler:minify', 'copy:static_resources', 'closurecompiler:minify_3rd_party_libs', 'cssmin', ]);
grunt.registerTask('no-uglify', ['typescript', 'copy:js_to_generated_js', 'requirejs', 'copy:js_to_min_js', 'copy:static_resources', 'copy:css_files']);
};