-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
137 lines (119 loc) · 3.99 KB
/
Gruntfile.js
File metadata and controls
137 lines (119 loc) · 3.99 KB
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
'use strict';
module.exports = function (grunt) {
require('time-grunt')(grunt);
// Individual configurations for all the tasks
grunt.initConfig({
typescript: {
base: {
src: ['src/js/**/*.ts'],
dest: 'src/js/',
options: {
module: 'commonjs',
target: 'es5',
rootDir: 'src/js/',
sourceMap: false,
declaration: false
}
}
},
// Javascript validator. Skip files in '.jshintignore'
jshint: {
options: {
jshintrc: 'config/validators/.jshintrc', ignores: []
},
target: {
src: ['src/js/**/*.js']
}
},
// CSS validator. Skip files with ! in front of in src
csslint: {
options: {
csslintrc: 'config/validators/.csslintrc'
},
target: {
src: ['src/css/**/*.css']
}
},
// Clean folders. Add some sub-tasks to clean every output folder
clean: {
dist: {
src: ['dist'], options: {
force: true
}
}
},
// Enables a watcher for the files specifies and fires an event to the http server
watch: {
files: ['src/**/*.*'],
tasks: ['test']
},
// Configure the concat and uglify of de js and css
useminPrepare: {
html: 'src/*.html',
options: {
dest: 'dist/www'
}
},
// Execute the tasks of minifying, compression, etc...
usemin: {
html: 'dist/www/*.html',
css: ['dist/www/*.css']
},
// Copy the html and images
copy: {
release: {
files: [{
expand: true,
cwd: 'src',
src: ['images/*.{png,gif,jpg,svg}', 'img/*.{png,gif,jpg,svg}', 'fonts/*', '*.html'],
dest: 'dist/www'
}]
},
config: {
files: [{expand: true, cwd: 'config', src: ['*.xml', '*.plist'], dest: 'dist/config'}]
},
assets: {
files: [{expand: true, cwd: 'assets', src: ['*.*', '**/*.*'], dest: 'dist/assets'}]
},
config_file: {
files: [{expand: true, cwd: '', src: 'adaptive.yml', dest: 'dist'}]
}
},
// Adds a custom file name to avoid cache
filerev: {
options: {
encoding: 'utf8', algorithm: 'md5', length: 20
},
release: {
files: [{src: ['dist/www/images/*.{png,gif,jpg,svg}', 'dist/www/*.js', 'dist/www/*.css']}]
}
},
htmlmin: {
dist: {
options: {
removeComments: true, collapseWhitespace: true
},
files: [{expand: true, cwd: 'dist', src: '*.html', dest: 'dist/www/'}]
}
},
replace: {
html: {
src: ['dist/www/*.css'],
overwrite: true,
replacements: [
{from: '../fonts/', to: 'fonts/'},
{from: '../images/', to: 'images/'},
{from: '../img/', to: 'img/'}
]
}
}
});
grunt.registerTask('test', ['typescript', 'jshint', 'csslint']);
grunt.registerTask('build', ['test', 'clean:dist', 'useminPrepare', 'concat:generated', 'cssmin:generated',
'uglify:generated', 'copy:release', 'replace:html', 'copy:config', 'copy:assets', 'copy:config_file', 'filerev', 'usemin', 'htmlmin']);
// alias tasks
grunt.registerTask('dist', ['build']);
grunt.registerTask('default', ['test']);
// Load all grunt tasks matching the `grunt-*` pattern.
require('load-grunt-tasks')(grunt);
};