-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
161 lines (148 loc) · 4.99 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Clear all files/subdirectories from "build" directory
clean: {
main: [
'build/**/*',
'build/**/.htaccess'
]
},
// Copy the directory structure and files from "src" --> "build", excluding directory branches
// with "archive" in their names.
copy: {
main: {
files: [
{
expand:true,
cwd:'src',
src: ['**/*', '**/.htaccess', '!**/archive/**'],
dest:'build' }
]
}
},
// Minify JS files (turn on source mapping and apply timestamp banner)
uglify: {
options: {
sourceMap: true,
banner: '/*! LMD Liberia MOH build: <%= grunt.template.today("yyyy-mm-dd hh:dd:ss") %> */\n'
},
main: {
files: [{
expand: true,
cwd: 'build/',
src: ['js/*.js'],
dest: 'build/'
}]
}
},
// Minify CSS files (turn on source mapping)
cssmin: {
options: {
sourceMap: true
},
main: {
files: [{
expand: true,
cwd: 'build/',
src: ['css/*.css'],
dest: 'build/'
}]
}
},
// Add revision numbers to JS/CSS files; these will automatically change when the file contents change
// e.g. loadContents.js --> loadContents.aj3o48xo.js
filerev: {
main: {
src: [
'build/js/*.js',
'build/css/*.css'
]
}
},
// Replace references to the filerev'd JS/CSS files
// e.g. <script src='../js/loadContents.js'> --> <script src='../js/loadContents.aj3o48xo.js'>
filerev_replace: {
options: {
assets_root: 'build/'
},
main: {
src: [
'build/pages/*',
'build/forms/*.html',
'build/forms/old/*.html',
'build/fragments_portal/*'
]
}
},
// Minify HTML/PHP files
htmlmin: {
options: {
collapseBooleanAttributes: true,
// collapseWhitespace: true, // !!!!! this currently breaks PHP !!!!!
// preserveLineBreaks: true, // !!!!! this currently breaks PHP !!!!!
minifyCSS: true,
removeAttributeQuotes: true,
removeComments: true,
removeRedundantAttributes: true
},
main: {
files: [{
expand: true,
cwd: 'build/',
src: [
'forms/*.html',
'forms/old/*.html',
'fragments_portal/*.html',
'pages/*.{php,html}'
],
dest: 'build/'
}]
}
},
// Dynamically create the AppCache manifest file
manifest: {
options: {
verbose: false,
},
main: {
src: [
'lib/bootstrap-3.2.0-dist/css/*.css',
'lib/bootstrap-3.2.0-dist/js/*.js',
'lib/jquery-ui-1.11.1/*.{css,js}',
'lib/jquery-ui-1.11.1/images/ui-icons*.png',
'lib/jquery.min.js',
'build/images/*.{gif,png}',
'build/css/fhwForms.*.css',
'build/css/page_deqa.*.css',
'build/forms/*.html',
'build/forms/old/*.html',
'build/pages/header_bootstrap.html',
'build/pages/page_deqa.html',
'build/pages/tool_viewLocalRecords.html',
'build/js/LMD_fileSystemHelper.*.js',
'build/js/LMD_utilities.*.js',
'build/js/page_deqa.*.js',
'build/js/fhwForms.*.js',
'build/js/formHelper.*.js',
'build/js/formValidate.*.js',
'build/js/loadContents.*.js'
],
dest: 'lmdliberiamoh_v12.appcache'
}
}
});
// Automatically run "grunt.loadNpmTasks" for all plugins
require('load-grunt-tasks')(grunt);
// Register default tasks
grunt.registerTask('default', [
'clean',
'copy',
'uglify',
'cssmin',
'filerev',
'filerev_replace',
'htmlmin',
'manifest'
]);
};