-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.js
120 lines (115 loc) · 4.02 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
module.exports = function (grunt) {
grunt.initConfig({
srcDir: './app',
distDir: './public',
clean: {
on_start: ['<%= distDir %>'],
on_finish: []
},
htmlmin:{
dist: {
options:{
removeComments: true,
collapseWhitespace: true
},
expand:true,
cwd:'<%= distDir %>',
src: ['**/*.html'],
dest: '<%= distDir %>'
}
},
//correct the index to pickup right css file
'string-replace': {
inline: {
files: {
'<%= distDir %>/index.html': '<%= distDir%>/index.html'
},
options: {
replacements: [
{
pattern: 'app.css',
replacement: 'app.min.css'
},
{
pattern: 'bootstrap.css',
replacement: 'bootstrap.min.css'
}
]
}
}
},
cssmin: {
options: {
keepSpecialComments: 0
},
dev: {
files: {
'<%= srcDir %>/app.css': ['./app/css/app.css',
'./app/home/home.css',
'./app/play/board.css',
'./app/validateemailid/validateemailid.css']
}
},
release: {
files: {
'<%= distDir %>/app.min.css': ['./app/css/app.css', './app/home/home.css', './app/play/board.css']
}
}
},
//the below replace uses @@key syntax for finding the replacing word
replace: {
dist_build_time: {
options:{
variables:{
"build-time": (new Date()).getTime().toString()
},
prefix:'@@'
},
files: [
{src: ['<%=distDir%>/index.html'], dest: './'}
]
}
},
requirejs: {
//https://github.com/requirejs/r.js/blob/master/build/example.build.js
compile: {
options: {
optimize: 'uglify2',
uglify2: {
mangle:true
},
baseUrl: './',
appDir: '<%= srcDir %>',
dir:'<%= distDir %>',
generateSourceMaps:false,
removeCombined: true,
fileExclusionRegExp: /^(r|build)\.js$/,
modules: [
{
name: 'require-config'
}
],
preserveLicenseComments: true,
mainConfigFile: "./app/require-config.js"
}
}
}
});
grunt.registerTask('dev', ['cssmin:dev']);
//release
grunt.registerTask('default', 'release');
grunt.registerTask('clean', 'clean');
grunt.registerTask('cssmin', 'cssmin');
grunt.registerTask('string-replace', 'string-replace:inline');
grunt.registerTask('htmlmin', 'htmlmin');
grunt.registerTask('replace', 'replace');
grunt.registerTask('release', ['clean:on_start', 'requirejs', 'cssmin:release', 'htmlmin', 'string-replace', 'replace']);
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-replace');
};