This document provides instructions for developers working on the Sample Data Generator plugin.
- Node.js (v14 or higher)
- npm (v6 or higher)
- Install dependencies:
npm installMinify CSS and JavaScript files:
grunt minifyThis will create:
admin/css/admin.min.cssfromadmin/css/admin.cssadmin/js/admin.min.jsfromadmin/js/admin.js
The plugin automatically loads minified files if they exist, otherwise falls back to the original files.
Create a production-ready ZIP file:
grunt releaseThis will:
- Minify all CSS and JS files
- Create a clean copy of the plugin in the
release/directory - Exclude development files (node_modules, Gruntfile.js, etc.)
- Include only minified CSS/JS files (not the source files)
- Create a ZIP file:
release/sample-data-generator-{version}.zip
The ZIP file is ready for distribution and WordPress.org submission.
Running grunt without arguments runs the minify task:
gruntsample-data-generator/
├── admin/
│ ├── css/
│ │ ├── admin.css # Source CSS
│ │ └── admin.min.css # Minified CSS (generated)
│ └── js/
│ ├── admin.js # Source JavaScript
│ └── admin.min.js # Minified JS (generated)
├── includes/ # PHP classes
├── release/ # Release packages (generated)
├── .gitignore # Git ignore rules
├── Gruntfile.js # Grunt configuration
├── package.json # NPM dependencies
└── sample-data-generator.php # Main plugin file
-
Make changes to source files:
- Edit
admin/css/admin.cssfor styles - Edit
admin/js/admin.jsfor scripts - Edit PHP files in
includes/
- Edit
-
Test your changes:
- The plugin loads source files during development
- Minified files are only loaded if they exist
-
Before committing:
- Run
grunt minifyto generate minified files - Test with minified files
- Run
-
Creating a release:
- Update version in
package.json - Update version in
sample-data-generator.php - Run
grunt release - Upload the ZIP from
release/directory
- Update version in
- Don't commit minified files to version control (they're gitignored)
- Always test with both source and minified files
- Keep source files clean and well-formatted
- Update version numbers in both
package.jsonand the main plugin file before release
Install Grunt CLI globally:
npm install -g grunt-cliClear the minified files and regenerate:
rm admin/css/*.min.css admin/js/*.min.js
grunt minifyCheck the exclusion patterns in Gruntfile.js under the copy:release task.