-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
executable file
·141 lines (114 loc) · 3.93 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
module.exports = function(grunt) {
// Do grunt-related things in here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
cfg: grunt.file.readJSON('config.json'),
//quality check pour les JS
jshint: {
options: {
"-W099": true, //mixed spaces and tabs (smarttabs)
"-W065": true, //radix param sur la fonction parseInt(),
"-W044": true, //escapes dans les regex
"-W004": true //{a} is already defined
},
all: ['<%= cfg.kidzou_path %>/public/asets/js/public.js',
'<%= cfg.kidzou_path %>/asets/js/kidzou-geo.js.js',
'<%= cfg.kidzou_path %>/asets/js/kidzou-storage.js',
'<%= cfg.kidzou_path %>/asets/js/kidzou-client.js',
'<%= cfg.kidzou_path %>/asets/js/kidzou-events.js',
'<%= cfg.kidzou_path %>/asets/js/kidzou-place.js',
'<%= cfg.theme_path %>/js/custom.js',
]
},
//déploiement des fichiers sur le serveur Apache
copy: {
//tache de déploiement du thème enfant
//et surcharge de certains fichiers du thème parent
divi: {
files: [
{expand:true, cwd: '<%= cfg.theme_path %>', src: ['**','!css/dev/**'], dest: '<%= cfg.wp_theme_root %>'},
{expand:true, cwd: '<%= cfg.theme_parent_path %>', src: ['**','!css/dev/**'], dest: '<%= cfg.wp_theme_parent_root %>'},
]
},
extraChild: {
files: [
{expand:true, cwd: '<%= cfg.extra_path %>', src: ['**','!css/dev/**'], dest: '<%= cfg.wp_extra_theme_root %>'},
]
},
//déploiement des fichiers du plugin Kidzou-4
k4: {
files: [
{expand:true, cwd: '<%= cfg.kidzou_path %>', src: ['**'], dest: '<%= cfg.wp_kidzou_root %>'}, // includes files in path and its subdirs,
]
},
//déploiement des fichiers du plugin Kidzou-5
k5: {
files: [
{expand:true, cwd: '<%= cfg.kidzou_5_path %>', src: ['**'], dest: '<%= cfg.wp_kidzou_5_root %>'}, // includes files in path and its subdirs,
]
},
},
//generation de documentation PHP
phpdocumentor: {
// Grunt Target used to generate a first documentation
plugin_kidzou : {
options: {
directory : 'plugins/kidzou-4',
target : 'docs/'
}
},
},
//tests de performance avec les API WebPageTest.org
perfbudget: {
default: {
options: {
url: 'http://www.kidzou.fr',
key: '<%= cfg.perf_api_key %>',
location : 'ec2-eu-central-1:Chrome'
}
}
},
babel: {
options: {
plugins: ['transform-object-rest-spread','transform-react-jsx'],
presets: ['es2015', 'react']
},
jsx: {
files: [{
expand: true,
cwd: '<%= cfg.theme_path %>/js/jsx/', // Custom folder
src: ['*.jsx'],
dest: '<%= cfg.theme_path %>/js', // Custom folder
ext: '.js'
}]
}
}
});
///////////////////////////////////////
// Modules
//
grunt.loadNpmTasks('grunt-contrib-jshint'); //
grunt.loadNpmTasks('grunt-contrib-copy'); //
//nettoyage des fichiers
grunt.loadNpmTasks('grunt-contrib-clean');
//Documentation
grunt.loadNpmTasks('grunt-phpdocumentor');
grunt.loadNpmTasks('grunt-babel');
// grunt.loadNpmTasks('grunt-css-docs');
//Perf tests avec les API de WebPageTest.org
//API key is A.3a80d0143024fccd375b277d90f0a07c
grunt.loadNpmTasks('grunt-perfbudget');
///////////////////////////////////////
// Tasks
//
grunt.registerTask('doc',['phpdocumentor:plugin_kidzou']);
grunt.registerTask('perf',['perfbudget']);
//lancement de grunt par defaut
//passage des Hint de qualité sur les .js
grunt.registerTask('k4', ['jshint','copy:divi', 'copy:k4']);
//Kidzou V et son theme Extra
grunt.registerTask('compile', ['babel']);
grunt.registerTask('default', ['copy:extraChild','copy:k5']);
//compilation des JSX en .js
// grunt.registerTask('deploy', ['babel','copy:divi', 'copy:k4']);
};