This repository has been archived by the owner on May 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
123 lines (110 loc) · 3.16 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
module.exports = function( grunt ) {
// Project Configuration
grunt.initConfig( {
pkg : grunt.file.readJSON( 'package.json' ),
srcFiles : 'src/*.js',
buildSrcFile : 'build/<%= pkg.name %>.js',
buildSrcMinFile : 'build/<%= pkg.name %>.min.js',
buildSrcMinVersionFile : 'build/<%= pkg.name %>-<%= pkg.version %>.min.js',
cssSrcFile : 'src/*.css',
buildCssSrcFile : 'build/<%= pkg.name %>.css',
buildCssSrcMinFile : 'build/<%= pkg.name %>.min.css',
testFiles : 'spec/*.js',
domtestFiles : 'spec/dom/*.html',
vendorFiles : 'dependencies/*.js',
concat : {
css : {
options : {
separator : ''
},
src : [ '<%= cssSrcFile %>' ],
dest : '<%= buildCssSrcFile %>'
},
js : {
options : {
separator : ''
},
src : [ '<%= srcFiles %>' ],
dest : '<%= buildSrcFile %>'
}
},
uglify : {
options : {
banner : '/**\n' +
' * <%= pkg.name %> - v<%= pkg.version %> - build <%= grunt.template.today("yyyy-mm-dd HH:mm:ss") %>\n' +
' * Copyright (c) 2014-2015 Selcher;\n' +
' * Distributed under the terms of the MIT license.\n' +
' */\n'
},
build : {
src : '<%= buildSrcFile %>',
dest : '<%= buildSrcMinFile %>'
}
},
cssmin : {
css : {
src : '<%= buildCssSrcFile %>',
dest : '<%= buildCssSrcMinFile %>'
}
},
copy : {
build : {
cwd : '',
src : [ '<%= buildSrcMinFile %>' ],
dest : '<%= buildSrcMinVersionFile %>',
expand : false
}
},
jshint : {
all : [ 'Gruntfile.js', '<%= srcFiles %>' ]
},
watch : {
files : [ '<%= srcFiles %>', 'Gruntfile.js' ],
tasks : [ 'qunit', 'jshint',
'concat', 'cssmin', 'uglify', 'copy' ]
},
notify : {
uglify : {
options : {
title : 'Minification complete',
message : 'minification completed successfully'
}
}
},
jasmine : {
test : {
src : '<%= srcFiles %>',
options : {
specs : '<%= testFiles %>',
vendor : [ '<%= vendorFiles %>' ],
}
}
},
qunit : {
all : [ '<%= domtestFiles %>' ]
}
} );
// Load the plugins
// uglify -> minify
// js hint -> code check
// watch -> watch file changes
// notify -> show notification
// grunt.loadNpmTasks( 'grunt-contrib-uglify' );
// grunt.loadNpmTasks( 'grunt-contrib-jshint' );
// grunt.loadNpmTasks( 'grunt-contrib-watch' );
// grunt.loadNpmTasks( 'grunt-notify' );
// grunt.loadNpmTasks( 'grunt-contrib-jasmine' );
// Replace multiple loadNpmTasks with matchdep and let it automatically add them
require( 'matchdep' ).filterDev( 'grunt-*' ).forEach( grunt.loadNpmTasks );
// load Npm tasks... alertnative to matchdep
// require( 'load-grunt-tasks' )( grunt, [ 'grunt-*', '!grunt-template-jasmine-requirejs' ] );
// Defalt task : just minify code
grunt.registerTask( 'default', [ 'qunit', 'jshint', 'concat', 'cssmin', 'uglify', 'copy', 'notify' ] );
// Development : watch for file changes and run:
// 1. jasmine for code testing
grunt.registerTask( 'dev', [ 'watch' ] );
// Production : check code and then minify
grunt.registerTask( 'prod', [ 'qunit', 'jshint', 'concat', 'cssmin', 'uglify', 'copy', 'notify' ] );
// Test: run tests
grunt.registerTask( 'test', [ 'qunit' ] );
};