forked from amsul/pickadate.js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
158 lines (123 loc) · 4.53 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
/*!
* This Gruntfile is used to build the project files.
*/
/*jshint
node: true
*/
module.exports = function( grunt ) {
// Read the package manifest.
var packageJSON = grunt.file.readJSON( 'package.json' )
// Load the NPM tasks.
grunt.loadNpmTasks( 'grunt-contrib-watch' )
grunt.loadNpmTasks( 'grunt-contrib-jshint' )
grunt.loadNpmTasks( 'grunt-contrib-qunit' )
grunt.loadNpmTasks( 'grunt-contrib-less' )
grunt.loadNpmTasks( 'grunt-contrib-cssmin' )
grunt.loadNpmTasks( 'grunt-contrib-uglify' )
grunt.loadNpmTasks( 'grunt-autoprefixer' )
// Setup the initial configurations.
grunt.initConfig({
// Add the package data.
pkg: packageJSON,
// Set up the directories.
dirs: {
tests: 'tests',
lib: {
src: 'lib',
min: 'lib/compressed'
},
themes: {
src: 'lib/themes-source',
dest: 'lib/themes',
min: 'lib/compressed/themes'
},
translations: {
src: 'lib/translations',
min: 'lib/compressed/translations'
},
},
// Compile LESS into CSS.
less: {
options: {
style: 'expanded'
},
themes: {
files: {
'<%= dirs.themes.dest %>/default.css': [ '<%= dirs.themes.src %>/base.less', '<%= dirs.themes.src %>/default.less' ],
'<%= dirs.themes.dest %>/classic.css': [ '<%= dirs.themes.src %>/base.less', '<%= dirs.themes.src %>/classic.less' ],
'<%= dirs.themes.dest %>/default.date.css': [ '<%= dirs.themes.src %>/base.date.less', '<%= dirs.themes.src %>/default.date.less' ],
'<%= dirs.themes.dest %>/default.time.css': [ '<%= dirs.themes.src %>/base.time.less', '<%= dirs.themes.src %>/default.time.less' ],
'<%= dirs.themes.dest %>/classic.date.css': [ '<%= dirs.themes.src %>/base.date.less', '<%= dirs.themes.src %>/classic.date.less' ],
'<%= dirs.themes.dest %>/classic.time.css': [ '<%= dirs.themes.src %>/base.time.less', '<%= dirs.themes.src %>/classic.time.less' ],
'<%= dirs.themes.dest %>/rtl.css': [ '<%= dirs.themes.src %>/rtl.less' ]
}
}
},
// Lint the files.
jshint: {
options: {
jshintrc: true
},
gruntfile: 'Gruntfile.js',
lib: [
'<%= dirs.tests %>/units/*.js',
'<%= dirs.lib.src %>/**/*.js',
// Ignore the legacy and minified files.
'!<%= dirs.lib.src %>/legacy.js',
'!<%= dirs.lib.src %>/compressed/**/*.js'
]
},
// Minify all the things!
uglify: {
options: {
preserveComments: 'some'
},
lib: {
files: [
{
expand : true,
cwd : '<%= dirs.lib.src %>',
src : [ '**/*.js', '!compressed/**/*.js' ],
dest : '<%= dirs.lib.min %>'
}
]
}
},
cssmin: {
lib: {
expand: true,
cwd: '<%= dirs.themes.dest %>',
src: [ '**/*.css', '!compressed/**/*.css' ],
dest: '<%= dirs.themes.min %>'
}
},
// Prefix the styles.
autoprefixer: {
options: {
browsers: [ '> 5%', 'last 2 versions', 'ie 8', 'ie 9' ]
},
themes: {
src: '<%= dirs.themes.dest %>/**/*.css'
},
},
// Unit test the files.
qunit: {
lib: [ '<%= dirs.tests %>/units/all.htm' ]
},
// Watch the project files.
watch: {
develop: {
files: [
'<%= dirs.themes.src %>/**/*.less'
],
tasks: [ 'develop-once' ]
},
}
}) //grunt.initConfig
// Register the tasks.
grunt.registerTask( 'default', [ 'develop' ] )
grunt.registerTask( 'develop', [ 'develop-once', 'watch:develop' ] )
grunt.registerTask( 'develop-once', [ 'less:themes', 'autoprefixer:themes' ] )
grunt.registerTask( 'package', [ 'develop-once', 'uglify', 'cssmin' ] )
grunt.registerTask( 'test', [ 'jshint', 'qunit' ] )
} //module.exports