But, the files are not all in one place and we don’t want to keep updating the Gruntfile configuration with complex glob rules – or perhaps the list of files changes based on configuration options defined somewhere else.
In the case of the Q Plugin, a file called q.module.json is generated when the settings are updated from inside the WordPress admin – you can see the specific action in the codebase – it is hooked to an ACF options page save routine.
Below is a very simplified version of the json file that is produced – showing a single file under the property
Below is a slimmed-down gruntfile showing how we can use the
grunt.file method to read the json file data and then assign an object of values from the
- The data stored in the file is converted to json format via the PHP function
grunt.filemethod has a
readJSONproperty which enables us to directly import the data from the json file
- Enable logging via –verbose options when calling Grunt commands to get detailed feedback and locate issues.