-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathGruntfile.js
84 lines (73 loc) · 2.81 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
module.exports = function(grunt) {
var country = grunt.option('country'),
size = grunt.option('size') || 'default,large',
files = [
'css/payment-methods.css',
'css/countries/' + country + '/payment-methods.css'
],
sizeCollection = size.split(','),
destination = 'build/payment-methods.' + country + '__' + size + '.css';
sizeCollection.forEach(function (e) {
files.push('css/countries/' + country + '/' + e + '/payment-methods.css');
});
if (sizeCollection.length > 1) {
// Rename file when all sizes
destination = 'build/payment-methods.' + country + '.css'
}
// Project configuration.
grunt.initConfig({
'pkg': grunt.file.readJSON('package.json'),
'concat': {
'build': {
'src': files,
'dest': destination
}
},
'copy': {
'main': {
'files': [{
'expand': true,
// Source folder
'cwd': 'build/',
// Source files
'src': [
'payment-methods.*.css',
'payment-methods.*__*.css'
],
// Destination folder
'dest': 'dist/',
'rename': function (dest, src) {
return dest + src.replace('/__*/', '');
}
}]
},
'images': {
'files': [
{
'src': 'css/countries/' + country + '/default/payment-methods-default.png',
'dest': 'dist/images/' + country + '/payment-methods-default.png'
},
{
'src': 'css/countries/' + country + '/default/[email protected]',
'dest': 'dist/images/' + country + '/[email protected]'
},
{
'src': 'css/countries/' + country + '/large/payment-methods-large.png',
'dest': 'dist/images/' + country + '/payment-methods-large.png'
},
{
'src': 'css/countries/' + country + '/large/[email protected]',
'dest': 'dist/images/' + country + '/[email protected]'
},
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
// Default task(s).
grunt.registerTask('default', []);
grunt.registerTask('build', ['concat']);
grunt.registerTask('dist', ['copy:main']);
grunt.registerTask('images', ['copy:images']);
};