forked from daniel-nagy/md-data-table
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
207 lines (186 loc) · 4.41 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
module.exports = function (grunt) {
'use strict';
function banner() {
return '/*\n' +
' * Angular Material Data Table\n' +
' * https://github.com/daniel-nagy/md-data-table\n' +
' * @license MIT\n' +
' * v' + getVersion() + '\n' +
' */\n' +
'(function (window, angular, undefined) {\n\'use strict\';\n\n';
}
function getVersion() {
return grunt.file.readJSON('./bower.json').version;
}
// load plugins
require('load-grunt-tasks')(grunt, {scope: 'devDependencies'});
grunt.initConfig({
config: {
livereload: 35729
},
// Add vendor prefixes
autoprefixer: {
options: {
browsers: ['last 2 versions']
},
app: {
files: {
'app/app.css': 'app/app.css'
}
},
build: {
files: {
'dist/md-data-table.css': 'dist/md-data-table.css'
}
}
},
// remove generated files
clean: {
app: 'app/app.css',
build: '.temp',
dist: 'dist'
},
// condense javascript into a single file
concat: {
options: {
banner: banner(),
footer: '\n\n})(window, angular);',
process: function (src) {
return src.replace(/^'use strict';\s*/, '');
},
separator: '\n\n'
},
build: {
files: {
'dist/md-data-table.js': ['.temp/templates.js', 'src/**/*.js']
}
}
},
// static web server
connect: {
app: {
options: {
port: 8000,
// hostname: '127.0.0.1',
hostname: '0.0.0.0',
livereload: '<%= config.livereload %>',
base: ['bower_components', 'dist', 'app']
}
}
},
// minify css files
cssmin: {
build: {
files: {
'dist/md-data-table.min.css': 'dist/md-data-table.css'
}
}
},
// convert templates to javascript and load them into
// the template cache
html2js: {
build: {
options: {
base: 'app/md-data-table',
module: 'md.table.templates',
quoteChar: '\'',
rename: function(moduleName) {
return moduleName.split('/').pop();
}
},
files: {
'.temp/templates.js': ['src/templates/*.html', 'src/icons/*.svg']
}
}
},
// report bad javascript syntax, uses jshint-stylish for
// more readable logging to the console
jshint: {
options: {
jshintrc: '.jshintrc',
reporter: require('jshint-stylish'),
force: true
},
build: 'src/**/*.js',
app: ['app/app.js', 'app/scripts/**/*.js']
},
// compile less
less: {
app: {
files: {
'app/app.css': 'app/styles/app.less'
}
},
build: {
files: {
'dist/md-data-table.css': 'src/styles/md-table.less'
}
}
},
// minify javascript files
uglify: {
build: {
files: {
'dist/md-data-table.min.js': 'dist/md-data-table.js'
}
}
},
// perform tasks on file change
watch: {
options: {
livereload: '<%= config.livereload %>'
},
appLess: {
files: 'app/styles/**/*.less',
tasks: ['less:app', 'autoprefixer:app']
},
appScripts: {
files: ['app/app.js', 'app/scripts/**/*.js'],
tasks: 'jshint:app'
},
appTemplates: {
files: 'app/templates/**/*.html'
},
buildLess: {
files: 'src/**/*.less',
tasks: ['less:build', 'autoprefixer:build']
},
buildScripts: {
files: 'src/**/*.js',
tasks: ['jshint:build', 'concat:build']
},
buildTemplates: {
files: 'src/**/*.html',
tasks: ['html2js:build', 'concat:build']
},
gruntfile: {
files: 'Gruntfile.js'
},
index: {
files: 'app/index.html'
}
}
});
grunt.registerTask('default', function () {
// buld the md-data-table module
grunt.task.run('build');
// start the app
grunt.task.run('serve');
});
grunt.registerTask('build', [
'jshint:build',
'less:build',
'autoprefixer:build',
'cssmin:build',
'html2js:build',
'concat:build',
'uglify:build'
]);
grunt.registerTask('serve', [
'jshint:app',
'less:app',
'autoprefixer:app',
'connect:app',
'watch'
]);
};