-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
127 lines (113 loc) · 3 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
module.exports = function ( grunt ) {
// Auto-load the needed grunt tasks
// require('load-grunt-tasks')(grunt);
require( 'load-grunt-tasks' )( grunt, { pattern: ['grunt-*'] } );
var config = {
tmpdir: '.tmp/',
phpFileRegex: '[^/]+\.php$',
phpFileInSubfolderRegex: '.*?\.php$',
pluginSlug: 'custom-sidebars-by-proteusthemes',
};
// configuration
grunt.initConfig( {
pgk: grunt.file.readJSON( 'package.json' ),
config: config,
// requireJS optimizer
// https://github.com/gruntjs/grunt-contrib-requirejs
requirejs: {
build: {
// Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
options: {
baseUrl: '',
mainConfigFile: 'assets/js/main.js',
optimize: 'uglify2',
preserveLicenseComments: true,
useStrict: true,
wrap: true,
name: 'bower_components/almond/almond',
include: 'assets/js/main',
out: 'assets/js/main.min.js'
}
}
},
// https://github.com/gruntjs/grunt-contrib-cssmin
cssmin: {
options: {
shorthandCompacting: false,
roundingPrecision: -1
},
target: {
files: {
'assets/css/main.min.css': ['assets/css/src/*.css']
}
}
},
// https://github.com/gruntjs/grunt-contrib-copy
copy: {
// create new directory for deployment
build: {
expand: true,
dot: false,
dest: config.pluginSlug + '/',
src: [
'*.php',
'readme.txt',
'LICENSE',
'assets/js/main.min.js',
'assets/css/main.min.css',
'bower_components/tinyscrollbar/lib/jquery.tinyscrollbar.min.js',
'inc/**',
'languages/**',
],
flatten: false
}
},
// https://www.npmjs.com/package/grunt-wp-i18n
makepot: {
plugin: {
options: {
domainPath: 'languages/',
include: [config.phpFileRegex, '^inc/'+config.phpFileInSubfolderRegex, '^views/'+config.phpFileInSubfolderRegex],
mainFile: config.pluginSlug + '.php',
potComments: 'Copyright (C) {year} ProteusThemes \n# This file is distributed under the GPL 2.0.',
potFilename: 'custom-sidebars-by-proteusthemes.pot',
potHeaders: {
poedit: true,
'report-msgid-bugs-to': 'http://support.proteusthemes.com/',
},
type: 'wp-plugin',
updateTimestamp: false,
updatePoFiles: true,
}
},
},
// https://www.npmjs.com/package/grunt-po2mo
po2mo: {
files: {
src: 'languages/*.po',
expand: true,
},
},
wp_readme_to_markdown: {
your_target: {
files: {
'readme.md': 'readme.txt'
},
},
},
} );
// Main build task
grunt.registerTask( 'build', [
'requirejs:build',
'cssmin',
] );
// update languages files
grunt.registerTask( 'plugin_i18n', [
'makepot:plugin',
'po2mo',
] );
// update languages files
grunt.registerTask( 'readme', [
'wp_readme_to_markdown',
] );
};